|
| 1 | +"""add move source |
| 2 | +
|
| 3 | +Revision ID: 6849ddf003e3 |
| 4 | +Revises: 4b0d6abd4d80 |
| 5 | +Create Date: 2026-10-03 02:32:35.605013 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence, Union |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | + |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision: str = '6849ddf003e3' |
| 16 | +down_revision: Union[str, Sequence[str], None] = '4b0d6abd4d80' |
| 17 | +branch_labels: Union[str, Sequence[str], None] = None |
| 18 | +depends_on: Union[str, Sequence[str], None] = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade() -> None: |
| 22 | + """Upgrade schema: an optional per-move source, for a move whose data comes from a |
| 23 | + different page than its boss's. Null means the move uses the boss's source. |
| 24 | + """ |
| 25 | + op.add_column('moves', sa.Column('source_name', sa.String(length=200), nullable=True)) |
| 26 | + op.add_column('moves', sa.Column('source_url', sa.Text(), nullable=True)) |
| 27 | + # Autogenerate does not detect check constraints; this mirrors models.Move. |
| 28 | + op.create_check_constraint('ck_moves_source_complete', 'moves', '(source_name IS NULL) = (source_url IS NULL)') |
| 29 | + |
| 30 | + |
| 31 | +def downgrade() -> None: |
| 32 | + """Downgrade schema.""" |
| 33 | + op.drop_constraint('ck_moves_source_complete', 'moves', type_='check') |
| 34 | + op.drop_column('moves', 'source_url') |
| 35 | + op.drop_column('moves', 'source_name') |
0 commit comments