lavina/migrations/0_first.sql

32 lines
858 B
SQL

create table users(
id integer primary key autoincrement not null,
name string unique not null
);
-- for development only, replace with properly hashed passwords later
create table challenges_plain_password(
user_id integer primary key not null,
password string not null
);
create table rooms(
id integer primary key autoincrement not null,
name string unique not null,
topic string not null,
message_count integer not null default 0
);
create table messages(
room_id integer not null,
id integer not null, -- unique per room, sequential in one room
content string not null,
primary key (room_id, id)
);
create table memberships(
user_id integer not null,
room_id integer not null,
status integer not null, -- 0 for not-joined, 1 for joined, 2 for banned
primary key (user_id, room_id)
);