feat: persist ranked season rollovers

This commit is contained in:
Josh Creek
2026-08-31 21:43:07 +01:00
parent bf4da9fd39
commit 4b5e40bff7
6 changed files with 82 additions and 3 deletions
+11
View File
@@ -112,6 +112,17 @@ CREATE TABLE seasons (
rolled_over_at TIMESTAMPTZ
);
CREATE TABLE ranked_season_rollovers (
player_id TEXT NOT NULL REFERENCES identities(player_id),
season_id TEXT NOT NULL REFERENCES seasons(season_id),
rating DOUBLE PRECISION NOT NULL,
deviation DOUBLE PRECISION NOT NULL,
volatility DOUBLE PRECISION NOT NULL,
ranked_games INTEGER NOT NULL CHECK (ranked_games >= 0),
rolled_over_at TIMESTAMPTZ NOT NULL,
PRIMARY KEY (player_id, season_id)
);
CREATE TABLE penalties (
penalty_id TEXT PRIMARY KEY,
player_id TEXT NOT NULL REFERENCES identities(player_id),
+2
View File
@@ -38,6 +38,8 @@ class MigrationTest(unittest.TestCase):
def test_seasons_are_ranked_only_and_penalties_are_durable(self):
self.assertIn("CHECK (playlist = 'ranked')", SQL)
self.assertIn("CREATE TABLE penalties", SQL)
self.assertIn("CREATE TABLE ranked_season_rollovers", SQL)
self.assertIn("PRIMARY KEY (player_id, season_id)", SQL)
self.assertIn("REFERENCES identities(player_id)", SQL)
self.assertIn("REFERENCES matches(match_id)", SQL)