Skip to content

Commit

Permalink
Add single column primary key to league_season_score (#20)
Browse files Browse the repository at this point in the history
* Closes #19 add single column primary key to league_season_score

* Add constraint for login and league_season to be unique in league_season_score

Co-authored-by: Clemens Borys <[email protected]>
  • Loading branch information
bukajsytlos and cleborys authored Mar 27, 2021
1 parent 0ea5d1b commit 5154c09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions migrations/V003__add_single_primary_key_to_score_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DROP TABLE league_season_score;

CREATE TABLE league_season_score
(
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
login_id MEDIUMINT(8) UNSIGNED NOT NULL,
league_season_id MEDIUMINT(8) UNSIGNED NOT NULL,
subdivision_id INT(10) UNSIGNED,
score INT,
game_count INT NOT NULL DEFAULT 0,
FOREIGN KEY (subdivision_id) REFERENCES league_season_division_subdivision (id),
UNIQUE INDEX (login_id, league_season_id),
UNIQUE INDEX (login_id, score, league_season_id)
);
1 change: 1 addition & 0 deletions service/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
league_season_score = Table(
"league_season_score",
metadata,
Column("id", Integer, primary_key=True),
Column("login_id", Integer, ForeignKey("login.id")),
Column("league_season_id", Integer, ForeignKey("league_season.id")),
Column(
Expand Down

0 comments on commit 5154c09

Please sign in to comment.