Fix SQLite circular dependency in batch migrations

Split batch_alter_table operations to avoid circular dependency
errors caused by the current_turn_team_id foreign key during
SQLite table recreation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 10:33:24 -04:00
parent 406daeeab1
commit bac02fecf5
2 changed files with 7 additions and 0 deletions

View File

@@ -30,9 +30,13 @@ def upgrade():
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('question_id', 'shared_with_user_id', name='unique_question_share')
)
# Split into separate batch operations to avoid SQLite circular dependency
# with the existing current_turn_team_id foreign key
with op.batch_alter_table('games', schema=None) as batch_op:
batch_op.add_column(sa.Column('completed_at', sa.DateTime(), nullable=True))
batch_op.add_column(sa.Column('winners', sa.JSON(), nullable=True))
with op.batch_alter_table('games', schema=None) as batch_op:
batch_op.drop_column('turn_order')
batch_op.drop_column('is_steal_mode')