forked from transact-rs/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sql
More file actions
83 lines (65 loc) 路 2.03 KB
/
Copy pathsetup.sql
File metadata and controls
83 lines (65 loc) 路 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- https://www.postgresql.org/docs/current/ltree.html
CREATE EXTENSION IF NOT EXISTS ltree;
-- https://www.postgresql.org/docs/current/cube.html
CREATE EXTENSION IF NOT EXISTS cube;
-- https://www.postgresql.org/docs/current/citext.html
CREATE EXTENSION IF NOT EXISTS citext;
-- https://www.postgresql.org/docs/current/hstore.html
CREATE EXTENSION IF NOT EXISTS hstore;
-- https://www.postgresql.org/docs/current/sql-createtype.html
CREATE TYPE status AS ENUM ('new', 'open', 'closed');
-- https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-DECLARING
CREATE TYPE inventory_item AS
(
name TEXT,
supplier_id INT,
price BIGINT
);
-- https://github.com/prisma/database-schema-examples/tree/master/postgres/basic-twitter#basic-twitter
CREATE TABLE tweet
(
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
text TEXT NOT NULL,
owner_id BIGINT
);
CREATE TABLE tweet_reply
(
id BIGSERIAL PRIMARY KEY,
tweet_id BIGINT NOT NULL REFERENCES tweet(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
text TEXT NOT NULL,
owner_id BIGINT
);
CREATE TYPE float_range AS RANGE
(
subtype = float8,
subtype_diff = float8mi
);
CREATE TABLE products (
product_no INTEGER,
name TEXT,
price NUMERIC CHECK (price > 0)
);
CREATE OR REPLACE PROCEDURE forty_two(INOUT forty_two INT = NULL)
LANGUAGE plpgsql AS 'begin forty_two := 42; end;';
CREATE TABLE test_citext (
foo CITEXT NOT NULL
);
CREATE SCHEMA IF NOT EXISTS foo;
CREATE TYPE foo."Foo" as ENUM ('Bar', 'Baz');
CREATE TABLE mytable(f HSTORE);
CREATE TABLE circles (
c circle,
EXCLUDE USING gist (c WITH &&)
);
CREATE DOMAIN positive_int AS integer CHECK (VALUE > 0);
CREATE DOMAIN percentage AS positive_int CHECK (VALUE <= 100);
CREATE TYPE person as (
id int,
age positive_int,
percent percentage
);
CREATE TYPE leaf_composite AS (prim integer);
CREATE DOMAIN domain AS leaf_composite;
CREATE TYPE root_composite AS (domain domain);