BUILD129 — три настраиваемых цвета команд

This commit is contained in:
2026-09-10 11:05:16 +03:00
parent f4f80d7837
commit a9278b5251
8 changed files with 243 additions and 62 deletions

View File

@@ -161,9 +161,25 @@ class HockeyDatabase:
migrated = self._migrate_operator_session_user_id()
Base.metadata.create_all(self.engine)
repaired = migrated + self._repair_game_table()
# BUILD129: preserve the behaviour of the legacy primary team
# colour when the explicit enable flag is introduced. Existing
# rows that already had color_hex become enabled exactly once,
# only on the migration that creates color_enabled.
team_repaired = self._repair_additive_table(Team)
repaired.extend(team_repaired)
if f"{Team.__tablename__}.color_enabled" in team_repaired:
with self.engine.begin() as connection:
connection.execute(
text(
"UPDATE \"hockey_teams\" SET \"color_enabled\" = TRUE "
"WHERE COALESCE(TRIM(\"color_hex\"), '') <> ''"
)
)
for model in (
OperatorSession,
Team,
TeamLeague,
Country,
PenaltyType,