|
| 1 | +"""add paging_token indexes |
| 2 | +
|
| 3 | +Revision ID: 713e40249322 |
| 4 | +Revises: 0c2f50c4d517 |
| 5 | +Create Date: 2025-06-26 14:13:08.992641 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | + |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision: str = '713e40249322' |
| 16 | +down_revision: str | None = '0c2f50c4d517' |
| 17 | +branch_labels: str | Sequence[str] | None = None |
| 18 | +depends_on: str | Sequence[str] | None = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade() -> None: |
| 22 | + with op.batch_alter_table('distribution_txs', schema=None) as batch_op: |
| 23 | + batch_op.create_index('idx_dtx_toid', [sa.literal_column('paging_token DESC')], unique=True) # type: ignore[arg-type] |
| 24 | + |
| 25 | + with op.batch_alter_table('minted_blocks', schema=None) as batch_op: |
| 26 | + batch_op.create_index('idx_block_toid', [sa.literal_column('paging_token DESC')], unique=True) # type: ignore[arg-type] |
| 27 | + |
| 28 | + with op.batch_alter_table('sinking_txs', schema=None) as batch_op: |
| 29 | + batch_op.create_index('idx_stx_toid', [sa.literal_column('paging_token DESC')], unique=True) # type: ignore[arg-type] |
| 30 | + |
| 31 | + |
| 32 | +def downgrade() -> None: |
| 33 | + with op.batch_alter_table('sinking_txs', schema=None) as batch_op: |
| 34 | + batch_op.drop_index('idx_stx_toid') |
| 35 | + |
| 36 | + with op.batch_alter_table('minted_blocks', schema=None) as batch_op: |
| 37 | + batch_op.drop_index('idx_block_toid') |
| 38 | + |
| 39 | + with op.batch_alter_table('distribution_txs', schema=None) as batch_op: |
| 40 | + batch_op.drop_index('idx_dtx_toid') |
0 commit comments