You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
557 B
SQL

CREATE TABLE IF NOT EXISTS sessions (
id TEXT PRIMARY KEY,
player_id TEXT NOT NULL REFERENCES players(id),
status TEXT NOT NULL DEFAULT 'active',
score INTEGER NOT NULL DEFAULT 0,
questions_answered INTEGER NOT NULL DEFAULT 0,
correct_answers INTEGER NOT NULL DEFAULT 0,
started_at TEXT NOT NULL DEFAULT (datetime('now')),
ended_at TEXT
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_sessions_active_player
ON sessions(player_id) WHERE status = 'active';