tijl.dev-core/migrations/00000002_flags.up.sql
tijl d246f5e270
All checks were successful
build / build (push) Successful in 40s
release-tag / release-image (push) Successful in 15m1s
flags
2024-08-26 14:22:24 +02:00

22 lines
749 B
SQL

CREATE TABLE app_flags_games (
game_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
game_seed UUID DEFAULT gen_random_uuid(),
uid VARCHAR DEFAULT NULL,
tags VARCHAR[] NOT NULL,
question_amount INT NOT NULL,
question_current INT DEFAULT 1 NOT NULL,
question_correct INT DEFAULT 0 NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
last_activity TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
FOREIGN KEY (uid) REFERENCES users (uid)
);
CREATE TABLE app_flags_games_answers (
game_id UUID NOT NULL,
question INT NOT NULL,
errors INT NOT NULL,
FOREIGN KEY (game_id) REFERENCES app_flags_games (game_id),
CONSTRAINT app_flags_games_answers_unique UNIQUE (game_id, question)
);