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 INTEGER PRIMARY KEY NOT NULL
|
|
|
|
);
|
|
|
|
|
2022-02-14 15:08:19 +00:00
|
|
|
INSERT OR IGNORE INTO gists_visibility (name) VALUES('private');
|
|
|
|
INSERT OR IGNORE INTO gists_visibility (name) VALUES('unlisted');
|
|
|
|
INSERT OR IGNORE INTO gists_visibility (name) VALUES('public');
|
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,
|
|
|
|
description TEXT DEFAULT NULL,
|
|
|
|
created INTEGER NOT NULL,
|
|
|
|
updated INTEGER NOT NULL,
|
2022-02-14 15:08:19 +00:00
|
|
|
visibility INTEGER NOT NULL references gists_visibility(ID),
|
2022-02-14 14:29:32 +00:00
|
|
|
public_id VARCHAR(32) UNIQUE NOT NULL,
|
|
|
|
ID INTEGER PRIMARY KEY NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS public_id_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 INTEGER NOT NULL,
|
|
|
|
ID INTEGER PRIMARY KEY NOT NULL
|
|
|
|
);
|