bbj2/server/cmd/schema.sql

52 lines
1.5 KiB
MySQL
Raw Normal View History

2022-04-21 02:19:01 +00:00
create table meta (
version text -- schema version
);
2022-04-22 19:49:36 +00:00
insert into meta values ("1.0.0");
2022-04-21 02:19:01 +00:00
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)
);
2022-04-24 17:09:56 +00:00
insert into users values (
2022-05-04 05:48:29 +00:00
"be105a40-6bd1-405f-9716-aa6158ac1eef", -- TODO replace UUID with incrementing int
2022-04-24 17:09:56 +00:00
"anon",
"8e97c0b197816a652fb489b21e63f664863daa991e2f8fd56e2df71593c2793f",
"",
"",
0,
0,
1650819851
);
2022-04-22 20:23:12 +00:00
-- TODO unique constraint on user_name?
2022-04-21 02:19:01 +00:00
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)
);