Change rematch event to change game

This commit is contained in:
2025-12-15 23:50:37 +07:00
parent 07e02ce32d
commit 339a212e57
14 changed files with 428 additions and 257 deletions

View File

@@ -0,0 +1,41 @@
"""Rename rematch event type to game_choice
Revision ID: 008_rename_to_game_choice
Revises: 007_add_event_assignment_fields
Create Date: 2024-12-15
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "008_rename_to_game_choice"
down_revision = "007_add_event_assignment_fields"
branch_labels = None
depends_on = None
def upgrade() -> None:
# Update event type from 'rematch' to 'game_choice' in events table
op.execute("UPDATE events SET type = 'game_choice' WHERE type = 'rematch'")
# Update event_type in assignments table
op.execute("UPDATE assignments SET event_type = 'game_choice' WHERE event_type = 'rematch'")
# Update activity data that references rematch event
op.execute("""
UPDATE activities
SET data = jsonb_set(data, '{event_type}', '"game_choice"')
WHERE data->>'event_type' = 'rematch'
""")
def downgrade() -> None:
# Revert event type from 'game_choice' to 'rematch'
op.execute("UPDATE events SET type = 'rematch' WHERE type = 'game_choice'")
op.execute("UPDATE assignments SET event_type = 'rematch' WHERE event_type = 'game_choice'")
op.execute("""
UPDATE activities
SET data = jsonb_set(data, '{event_type}', '"rematch"')
WHERE data->>'event_type' = 'game_choice'
""")