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

25 lines
706 B

-- Add up migration script here
CREATE TABLE IF NOT EXISTS games (
id SERIAL PRIMARY KEY NOT NULL,
-- what divison is the game a part of (usefl for stats)
division INTEGER NOT NULL,
team_home INTEGER NOT NULL,
team_away INTEGER NOT NULL,
start_at TIMESTAMPTZ NOT NULL,
end_at TIMESTAMPTZ NOT NULL,
-- home and away teams need to actually be teams
CONSTRAINT team_home_fk
FOREIGN KEY(team_home)
REFERENCES teams(id)
ON DELETE RESTRICT,
CONSTRAINT team_away_fk
FOREIGN KEY(team_away)
REFERENCES teams(id)
ON DELETE RESTRICT,
-- is divison real
CONSTRAINT division_fk
FOREIGN KEY(division)
REFERENCES divisions(id)
ON DELETE RESTRICT
);