monorepo/visions/server/migrations/01-initial-db/up.sql
Savanni D'Gerinel d0ba8d921d Create a user expiration time and make new users immediately expired
This is to give the ability to force the user to create a new password as soon as they log in.
2025-01-19 15:05:02 -05:00

44 lines
803 B
SQL

CREATE TABLE users(
uuid TEXT PRIMARY KEY,
name TEXT UNIQUE,
password TEXT,
admin BOOLEAN,
enabled BOOLEAN,
password_expires TEXT
);
CREATE TABLE sessions(
id TEXT PRIMARY KEY,
user_id TEXT,
FOREIGN KEY(user_id) REFERENCES users(uuid)
);
CREATE TABLE games(
uuid TEXT PRIMARY KEY,
gm TEXT,
game_type TEXT,
name TEXT,
FOREIGN KEY(gm) REFERENCES users(uuid)
);
CREATE TABLE characters(
uuid TEXT PRIMARY KEY,
game TEXT,
data TEXT,
FOREIGN KEY(game) REFERENCES games(uuid)
);
CREATE TABLE roles(
user_id TEXT,
game_id TEXT,
role TEXT,
FOREIGN KEY(user_id) REFERENCES users(uuid),
FOREIGN KEY(game_id) REFERENCES games(uuid)
);
INSERT INTO users VALUES ('admin', 'admin', '', true, true, datetime('now'));