2022-02-14 15:08:19 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS gists_visibility (
|
2022-02-14 14:29:32 +00:00
|
|
|
name VARCHAR(15) NOT NULL UNIQUE,
|
|
|
|
ID SERIAL PRIMARY KEY NOT NULL
|
|
|
|
);
|
|
|
|
|
2022-02-14 15:08:19 +00:00
|
|
|
INSERT INTO gists_visibility (name) VALUES('private') ON CONFLICT (name) DO NOTHING;
|
|
|
|
INSERT INTO gists_visibility (name) VALUES('unlisted') ON CONFLICT (name) DO NOTHING;
|
|
|
|
INSERT INTO gists_visibility (name) VALUES('public') ON CONFLICT (name) DO NOTHING;
|
2022-02-14 14:29:32 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS gists_gists (
|
|
|
|
owner_id INTEGER NOT NULL references gists_users(ID) ON DELETE CASCADE,
|
2022-02-14 15:08:19 +00:00
|
|
|
visibility INTEGER NOT NULL references gists_visibility(ID),
|
2022-02-14 14:29:32 +00:00
|
|
|
description TEXT DEFAULT NULL,
|
|
|
|
created timestamptz NOT NULL,
|
|
|
|
updated timestamptz NOT NULL,
|
|
|
|
public_id VARCHAR(32) UNIQUE NOT NULL,
|
|
|
|
ID SERIAL PRIMARY KEY NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX ON gists_gists(public_id);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS gists_comments (
|
|
|
|
owner_id INTEGER NOT NULL references gists_users(ID) ON DELETE CASCADE,
|
|
|
|
gist_id INTEGER NOT NULL references gists_gists(ID) ON DELETE CASCADE,
|
|
|
|
comment TEXT DEFAULT NULL,
|
|
|
|
created timestamptz NOT NULL DEFAULT now(),
|
|
|
|
ID SERIAL PRIMARY KEY NOT NULL
|
|
|
|
);
|