Files

40 lines
1.3 KiB
Python
Raw Permalink Normal View History

"""payout bump reserve: rounds.bump_reserve_sats (B-79)
Revision ID: e5a91c3d7b26
Revises: d3e8b15a7c42
Create Date: 2026-10-15 10:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'e5a91c3d7b26'
down_revision: Union[str, Sequence[str], None] = 'd3e8b15a7c42'
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-79 (DAT-73): the value of the bump reserve output a payout was created with. NULL for
every payout built before the reserve existed.
A plain add_column — never batch_alter_table, which on SQLite rebuilds the table and
silently drops the expression indexes (B-97, DAT-56).
"""
op.add_column("rounds", sa.Column("bump_reserve_sats", sa.BigInteger(), nullable=True))
def downgrade() -> None:
"""Downgrade schema."""
op.drop_column("rounds", "bump_reserve_sats")
# 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})")