feat: redesign match play and add broadcast tooling

This commit is contained in:
2026-09-29 02:52:56 +00:00
parent f417a831f7
commit 9b9aafefc1
348 changed files with 31588 additions and 11094 deletions

View File

@@ -0,0 +1,18 @@
-- Spectator predictions and tournament pick'ems.
CREATE TABLE IF NOT EXISTS prediction (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id text NOT NULL,
match_id uuid REFERENCES match(id) ON DELETE CASCADE,
tournament_match_id uuid REFERENCES tournament_match(id) ON DELETE CASCADE,
winner_team_id uuid NOT NULL REFERENCES team(id) ON DELETE CASCADE,
winner_score integer,
loser_score integer,
points integer,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT prediction_one_subject CHECK ((match_id IS NULL) <> (tournament_match_id IS NULL))
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_prediction_user_match ON prediction (user_id, match_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_prediction_user_tmatch ON prediction (user_id, tournament_match_id);
CREATE INDEX IF NOT EXISTS idx_prediction_match ON prediction (match_id);
CREATE INDEX IF NOT EXISTS idx_prediction_tmatch ON prediction (tournament_match_id);