Debian Codegraph @

tests/sqlite/setup.sql

raw
1 -- https://github.com/prisma/database-schema-examples/tree/master/postgres/basic-twitter#basic-twitter
2 CREATE TABLE tweet (
3 id BIGINT NOT NULL PRIMARY KEY,
4 text TEXT NOT NULL,
5 is_sent BOOLEAN NOT NULL DEFAULT TRUE,
6 owner_id BIGINT
7 );
8 INSERT INTO tweet(id, text, owner_id)
9 VALUES (1, '#sqlx is pretty cool!', 1);
10 --
11 CREATE TABLE tweet_reply (
12 id BIGINT NOT NULL PRIMARY KEY,
13 tweet_id BIGINT NOT NULL,
14 text TEXT NOT NULL,
15 owner_id BIGINT,
16 CONSTRAINT tweet_id_fk FOREIGN KEY (tweet_id) REFERENCES tweet(id)
17 );
18 INSERT INTO tweet_reply(id, tweet_id, text, owner_id)
19 VALUES (1, 1, 'Yeah! #sqlx is indeed pretty cool!', 1);
20 --
21 CREATE TABLE accounts (
22 id INTEGER NOT NULL PRIMARY KEY,
23 name TEXT NOT NULL,
24 is_active BOOLEAN
25 );
26 INSERT INTO accounts(id, name, is_active)
27 VALUES (1, 'Herp Derpinson', 1);
28 CREATE VIEW accounts_view as
29 SELECT *
30 FROM accounts;
31 --
32 CREATE TABLE products (
33 product_no INTEGER,
34 name TEXT,
35 price NUMERIC,
36 CONSTRAINT price_greater_than_zero CHECK (price > 0)
37 );