Files
plm-lottery/migrations/versions/53cc70d16e63_add_operational_params_to_round_config.py
T

60 lines
2.3 KiB
Python
Raw Normal View History

"""add operational params to round_config
Revision ID: 53cc70d16e63
Revises: 274efdcbfbcc
Create Date: 2026-07-21 14:44:09.866407
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '53cc70d16e63'
down_revision: Union[str, Sequence[str], None] = '274efdcbfbcc'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# server_default backfills the existing singleton row (if any) with the same
# defaults app/config.py used before these became DB-editable; dropped right
# after so new rows go through the ORM defaults instead of a stale constant.
op.add_column(
'round_config', sa.Column('round_duration_seconds', sa.Integer(), nullable=False, server_default='600')
)
op.add_column(
'round_config', sa.Column('round_cooldown_seconds', sa.Integer(), nullable=False, server_default='30')
)
op.add_column(
'round_config',
sa.Column('min_amount_sats', sa.BigInteger(), nullable=False, server_default='100000000'),
)
op.add_column(
'round_config', sa.Column('fee_rate_sat_vb', sa.Integer(), nullable=False, server_default='1')
)
op.add_column(
'round_config', sa.Column('rbf_timeout_seconds', sa.Integer(), nullable=False, server_default='900')
)
with op.batch_alter_table('round_config') as batch_op:
batch_op.alter_column('round_duration_seconds', server_default=None)
batch_op.alter_column('round_cooldown_seconds', server_default=None)
batch_op.alter_column('min_amount_sats', server_default=None)
batch_op.alter_column('fee_rate_sat_vb', server_default=None)
batch_op.alter_column('rbf_timeout_seconds', server_default=None)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('round_config', 'rbf_timeout_seconds')
op.drop_column('round_config', 'fee_rate_sat_vb')
op.drop_column('round_config', 'min_amount_sats')
op.drop_column('round_config', 'round_cooldown_seconds')
op.drop_column('round_config', 'round_duration_seconds')
# ### end Alembic commands ###