lavina/crates/lavina-core/migrations/0000_first.sql

37 lines
926 B
MySQL
Raw Normal View History

2024-03-31 11:10:58 +00:00
CREATE TABLE users
(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
2024-03-31 10:40:26 +00:00
name STRING UNIQUE NOT NULL
);
-- for development only, replace with properly hashed passwords later
CREATE TABLE challenges_plain_password
(
2024-03-31 11:10:58 +00:00
user_id INTEGER PRIMARY KEY NOT NULL,
password STRING NOT NULL
2024-03-31 10:40:26 +00:00
);
CREATE TABLE rooms
(
2024-03-31 11:10:58 +00:00
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name STRING UNIQUE NOT NULL,
topic STRING NOT NULL,
message_count INTEGER NOT NULL DEFAULT 0
2024-03-31 10:40:26 +00:00
);
2024-03-31 11:10:58 +00:00
CREATE TABLE messages
(
2024-03-31 10:40:26 +00:00
room_id INTEGER NOT NULL,
2024-03-31 11:10:58 +00:00
id INTEGER NOT NULL, -- unique per room, sequential in one room
content STRING NOT NULL,
2024-03-31 10:40:26 +00:00
PRIMARY KEY (room_id, id)
);
CREATE TABLE memberships
(
user_id INTEGER NOT NULL,
room_id INTEGER NOT NULL,
2024-03-31 11:10:58 +00:00
status INTEGER NOT NULL, -- 0 for not-joined, 1 for joined, 2 for banned
2024-03-31 10:40:26 +00:00
PRIMARY KEY (user_id, room_id)
);