From afd9c3c07040432a55647f32ca1167c38db24045 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 25 Jul 2022 11:41:59 -0500 Subject: [PATCH] oops forgot to commit schema --- server/cmd/db/schema.sql | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 server/cmd/db/schema.sql diff --git a/server/cmd/db/schema.sql b/server/cmd/db/schema.sql new file mode 100644 index 0000000..eb72af6 --- /dev/null +++ b/server/cmd/db/schema.sql @@ -0,0 +1,52 @@ +create table meta ( + version text -- schema version +); + +insert into meta values ("1.0.0"); + +create table users ( + user_id text, -- string (uuid1) + user_name text, -- string + auth_hash text, -- string (sha256 hash) + quip text, -- string (possibly empty) + bio text, -- string (possibly empty) + color int, -- int (from 0 to 6) + is_admin int, -- bool + created real -- floating point unix timestamp (when this user registered) +); + +insert into users values ( + "be105a40-6bd1-405f-9716-aa6158ac1eef", -- TODO replace UUID with incrementing int + "anon", + "8e97c0b197816a652fb489b21e63f664863daa991e2f8fd56e2df71593c2793f", + "", + "", + 0, + 0, + 1650819851 +); + +-- TODO unique constraint on user_name? +-- TODO foreign keys + +create table threads ( + thread_id text, -- uuid string + author text, -- string (uuid1, user.user_id) + title text, -- string + last_mod real, -- floating point unix timestamp (of last post or post edit) + created real, -- floating point unix timestamp (when thread was made) + reply_count int, -- integer (incremental, starting with 0) + pinned int, -- boolean + last_author text -- uuid string +); + + +create table messages ( + thread_id text, -- string (uuid1 of parent thread) + post_id int, -- integer (incrementing from 1) + author text, -- string (uuid1, user.user_id) + created real, -- floating point unix timestamp (when reply was posted) + edited int, -- bool + body text, -- string + send_raw int -- bool (1/true == never apply formatting) +);