feat: add durable matchmaking metadata schema

This commit is contained in:
Josh Creek
2026-08-31 20:35:34 +01:00
parent 637b522486
commit 7c4b64b50a
3 changed files with 38 additions and 3 deletions
+9 -2
View File
@@ -10,15 +10,16 @@ SQL = (Path(__file__).parent / "0001_initial.sql").read_text()
class MigrationTest(unittest.TestCase):
def test_durable_domains_and_fences_exist(self):
required_tables = {
"identities", "sessions", "queue_tickets", "proposals",
"identities", "sessions", "idempotency_keys", "queue_tickets", "proposals",
"proposal_participants", "matches", "match_participants",
"ratings", "result_receipts", "outbox", "audit_events",
"ratings", "seasons", "penalties", "result_receipts", "outbox", "audit_events",
}
for table in required_tables:
self.assertIn(f"CREATE TABLE {table}", SQL)
self.assertIn("queue_tickets_one_active_per_player", SQL)
self.assertIn("match_participants_one_active_match", SQL)
self.assertIn("UNIQUE (aggregate_type, aggregate_id, revision)", SQL)
self.assertIn("PRIMARY KEY (scope, idempotency_key)", SQL)
def test_redis_is_not_a_durable_dependency(self):
self.assertNotIn("CREATE TABLE redis", SQL.lower())
@@ -34,6 +35,12 @@ class MigrationTest(unittest.TestCase):
self.assertIn("participation_active BOOLEAN NOT NULL DEFAULT TRUE", SQL)
self.assertIn("WHERE participation_active", SQL)
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("REFERENCES identities(player_id)", SQL)
self.assertIn("REFERENCES matches(match_id)", SQL)
if __name__ == "__main__":
unittest.main()