generated from VLADIMIR/template
18 lines
663 B
SQL
18 lines
663 B
SQL
-- +goose Up
|
|
CREATE TABLE game_reviews (
|
|
id SERIAL PRIMARY KEY,
|
|
game_id INTEGER NOT NULL REFERENCES games (id) ON DELETE CASCADE,
|
|
team_id INTEGER NOT NULL REFERENCES teams (id) ON DELETE CASCADE,
|
|
rating INTEGER NOT NULL CHECK (rating BETWEEN 1 AND 5),
|
|
text TEXT NOT NULL CHECK (length(btrim(text)) > 0),
|
|
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected', 'hidden')),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
moderated_at TIMESTAMPTZ,
|
|
UNIQUE (game_id, team_id)
|
|
);
|
|
|
|
CREATE INDEX game_reviews_moderation ON game_reviews (status, created_at);
|
|
|
|
-- +goose Down
|
|
DROP TABLE game_reviews;
|