"""deposit confirmations and the held payout: round_config.deposit_confirmations, rounds.payout_blocked_at (B-82) Revision ID: f2c64a8d1e93 Revises: e5a91c3d7b26 Create Date: 2026-10-15 12:00:00.000000 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = 'f2c64a8d1e93' down_revision: Union[str, Sequence[str], None] = 'e5a91c3d7b26' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None _ACTIVE = "'open', 'closing', 'drawing', 'paying_out'" def upgrade() -> None: """Upgrade schema. B-82 (DAT-62, DAT-68): `round_config.deposit_confirmations` (default 6) is how many confirmations an output paying a user needs before it is credited as a deposit; `rounds.payout_blocked_at` marks a payout held because the winner's own bet left the chain. Both are plain add_column calls — never batch_alter_table, which on SQLite rebuilds the table and silently drops the expression indexes (B-97, DAT-56). """ op.add_column( "round_config", sa.Column("deposit_confirmations", sa.Integer(), server_default="6", nullable=False) ) op.add_column("rounds", sa.Column("payout_blocked_at", sa.DateTime(), nullable=True)) def downgrade() -> None: """Downgrade schema.""" op.drop_column("rounds", "payout_blocked_at") op.drop_column("round_config", "deposit_confirmations") # drop_column on SQLite is a table rebuild: recreate the expression index (B-97). op.execute("DROP INDEX IF EXISTS ix_rounds_single_active") op.execute(f"CREATE UNIQUE INDEX ix_rounds_single_active ON rounds ((1)) WHERE status IN ({_ACTIVE})")