Files
prod/migrations/20260831120000_create_team_answers_table.sql
2026-10-03 20:39:03 +07:00

18 lines
561 B
SQL

-- +goose Up
CREATE TABLE
IF NOT EXISTS team_answers (
id SERIAL PRIMARY KEY,
team_id INTEGER NOT NULL,
question_code TEXT NOT NULL,
answer TEXT NOT NULL DEFAULT '',
score INTEGER,
created_at TIMESTAMP NOT NULL DEFAULT NOW (),
updated_at TIMESTAMP NOT NULL DEFAULT NOW (),
CONSTRAINT fk_team_answers_team FOREIGN KEY (team_id) REFERENCES teams (id) ON DELETE CASCADE,
CONSTRAINT uq_team_answer UNIQUE (team_id, question_code)
);
-- +goose Down
DROP TABLE IF EXISTS team_answers;