| 1 |
-- https://www.postgresql.org/docs/current/ltree.html |
| 2 |
CREATE EXTENSION IF NOT EXISTS ltree; |
| 3 |
|
| 4 |
-- https://www.postgresql.org/docs/current/cube.html |
| 5 |
CREATE EXTENSION IF NOT EXISTS cube; |
| 6 |
|
| 7 |
-- https://www.postgresql.org/docs/current/citext.html |
| 8 |
CREATE EXTENSION IF NOT EXISTS citext; |
| 9 |
|
| 10 |
-- https://www.postgresql.org/docs/current/hstore.html |
| 11 |
CREATE EXTENSION IF NOT EXISTS hstore; |
| 12 |
|
| 13 |
-- https://www.postgresql.org/docs/current/sql-createtype.html |
| 14 |
CREATE TYPE status AS ENUM ('new', 'open', 'closed'); |
| 15 |
|
| 16 |
-- https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-DECLARING |
| 17 |
CREATE TYPE inventory_item AS |
| 18 |
( |
| 19 |
name TEXT, |
| 20 |
supplier_id INT, |
| 21 |
price BIGINT |
| 22 |
); |
| 23 |
|
| 24 |
-- https://github.com/prisma/database-schema-examples/tree/master/postgres/basic-twitter#basic-twitter |
| 25 |
CREATE TABLE tweet |
| 26 |
( |
| 27 |
id BIGSERIAL PRIMARY KEY, |
| 28 |
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), |
| 29 |
text TEXT NOT NULL, |
| 30 |
owner_id BIGINT |
| 31 |
); |
| 32 |
|
| 33 |
CREATE TABLE tweet_reply |
| 34 |
( |
| 35 |
id BIGSERIAL PRIMARY KEY, |
| 36 |
tweet_id BIGINT NOT NULL REFERENCES tweet(id), |
| 37 |
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), |
| 38 |
text TEXT NOT NULL, |
| 39 |
owner_id BIGINT |
| 40 |
); |
| 41 |
|
| 42 |
CREATE TYPE float_range AS RANGE |
| 43 |
( |
| 44 |
subtype = float8, |
| 45 |
subtype_diff = float8mi |
| 46 |
); |
| 47 |
|
| 48 |
CREATE TABLE products ( |
| 49 |
product_no INTEGER, |
| 50 |
name TEXT, |
| 51 |
price NUMERIC CHECK (price > 0) |
| 52 |
); |
| 53 |
|
| 54 |
CREATE OR REPLACE PROCEDURE forty_two(INOUT forty_two INT = NULL) |
| 55 |
LANGUAGE plpgsql AS 'begin forty_two := 42; end;'; |
| 56 |
|
| 57 |
CREATE TABLE test_citext ( |
| 58 |
foo CITEXT NOT NULL |
| 59 |
); |
| 60 |
|
| 61 |
CREATE SCHEMA IF NOT EXISTS foo; |
| 62 |
|
| 63 |
CREATE TYPE foo."Foo" as ENUM ('Bar', 'Baz'); |
| 64 |
|
| 65 |
CREATE TABLE mytable(f HSTORE); |