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.
28 lines
964 B
28 lines
964 B
1 year ago
|
-- Add up migration script here
|
||
|
CREATE TABLE IF NOT EXISTS games (
|
||
|
id SERIAL PRIMARY KEY NOT NULL,
|
||
1 year ago
|
-- this allows there to be special names like "Gold Medal Game", but the default will be the number of games already in the division + 1
|
||
|
-- NOTE: this is only done in the front end, the backend will not give a default value
|
||
|
name VARCHAR(255) NOT NULL,
|
||
1 year ago
|
-- what divison is the game a part of (usefl for stats)
|
||
|
division INTEGER NOT NULL,
|
||
1 year ago
|
team_home INTEGER NOT NULL,
|
||
|
team_away INTEGER NOT NULL,
|
||
1 year ago
|
start_at TIMESTAMPTZ NOT NULL,
|
||
|
end_at TIMESTAMPTZ NOT NULL,
|
||
1 year ago
|
-- 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)
|
||
1 year ago
|
ON DELETE RESTRICT,
|
||
|
-- is divison real
|
||
|
CONSTRAINT division_fk
|
||
|
FOREIGN KEY(division)
|
||
|
REFERENCES divisions(id)
|
||
1 year ago
|
ON DELETE RESTRICT
|
||
|
);
|