Debian Codegraph @

tests/mysql/setup.sql

raw
1 -- https://github.com/prisma/database-schema-examples/tree/master/postgres/basic-twitter#basic-twitter
2 CREATE TABLE tweet
3 (
4 id BIGINT PRIMARY KEY AUTO_INCREMENT,
5 created_at TIMESTAMP NOT NULL DEFAULT NOW(),
6 text TEXT NOT NULL,
7 owner_id BIGINT
8 );
9
10 CREATE TABLE tweet_reply
11 (
12 id BIGINT PRIMARY KEY AUTO_INCREMENT,
13 tweet_id BIGINT NOT NULL,
14 created_at TIMESTAMP NOT NULL DEFAULT NOW(),
15 text TEXT NOT NULL,
16 owner_id BIGINT,
17 CONSTRAINT tweet_id_fk FOREIGN KEY (tweet_id) REFERENCES tweet(id)
18 );
19
20 CREATE TABLE products (
21 product_no INTEGER,
22 name TEXT,
23 price NUMERIC CHECK (price > 0)
24 );
25
26 -- Create a user without a password to test passwordless auth.
27 CREATE USER 'no_password'@'%';
28
29 -- The minimum privilege apparently needed to connect to a specific database.
30 -- Granting no privileges, or just `GRANT USAGE`, gives an "access denied" error.
31 -- https://github.com/launchbadge/sqlx/issues/3484#issuecomment-2350901546
32 GRANT SELECT ON sqlx.* TO 'no_password'@'%';