vybe/db/1-init.sql

50 lines
1.0 KiB
SQL

CREATE TABLE users (
id integer primary key asc,
name text,
pubkey text,
created timestamp default current_timestamp
);
CREATE TABLE authentications (
user integer,
salt text,
foreign key(user) references users(id)
);
CREATE TABLE threads (
id integer primary key asc,
name text,
creator integer,
created timestamp default current_timestamp,
foreign key(creator) references users(id)
);
CREATE TABLE permissions (
thread integer,
user integer,
type text,
flexible boolean,
permission text,
value text,
foreign key(user) references users(id),
foreign key(thread) references threads(id)
)
CREATE TABLE members (
thread integer,
user integer,
foreign key(user) references users(id),
foreign key(thread) references threads(id)
)
CREATE TABLE posts (
id integer primary key asc,
user integer,
thread integer,
content text,
created timestamp default current_timestamp,
foreign key(user) references users(id),
foreign key(thread) references threads(id)
);
INSERT INTO threads (name) values ("meow");