vybe/db/1-init.sql

60 lines
1.4 KiB
MySQL
Raw Normal View History

2023-05-05 19:33:05 -07:00
CREATE TABLE users (
id integer primary key asc,
name text,
pubkey text,
created timestamp default current_timestamp
);
2023-05-07 18:43:57 -07:00
CREATE TABLE authentications (
user integer,
salt text,
2023-05-29 18:08:20 -07:00
created timestamp default current_timestamp,
2023-05-07 18:43:57 -07:00
foreign key(user) references users(id)
);
2023-05-05 19:33:05 -07:00
CREATE TABLE threads (
id integer primary key asc,
2023-05-08 20:51:17 -07:00
name text,
creator integer,
created timestamp default current_timestamp,
foreign key(creator) references users(id)
2023-05-05 19:33:05 -07:00
);
2023-05-09 00:04:48 -07:00
CREATE TABLE permissions (
thread integer,
user integer,
type text,
2023-05-29 18:08:20 -07:00
mutable boolean,
2023-05-09 00:04:48 -07:00
permission text,
value text,
foreign key(user) references users(id),
foreign key(thread) references threads(id)
2023-05-28 14:56:08 -07:00
);
2023-05-09 00:04:48 -07:00
CREATE TABLE members (
thread integer,
user integer,
2023-05-29 18:08:20 -07:00
key_delivery text,
created timestamp default current_timestamp,
2023-05-09 00:04:48 -07:00
foreign key(user) references users(id),
foreign key(thread) references threads(id)
2023-05-28 14:56:08 -07:00
);
2023-05-09 00:04:48 -07:00
2023-05-05 19:33:05 -07:00
CREATE TABLE posts (
id integer primary key asc,
user integer,
thread integer,
content text,
2023-05-29 18:08:20 -07:00
encrypted bool,
2023-05-05 19:33:05 -07:00
created timestamp default current_timestamp,
foreign key(user) references users(id),
foreign key(thread) references threads(id)
);
2023-05-29 18:08:20 -07:00
INSERT INTO threads (name) values ("meow");
INSERT INTO permissions
(thread, type, permission, value) values
(1, "everyone", "view", "true");
INSERT INTO permissions
(thread, type, permission, value) values
(1, "everyone", "post", "true");