diff options
Diffstat (limited to 'src/mailman/database')
| -rw-r--r-- | src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py b/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py index 00064bc1e..4dade211b 100644 --- a/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py +++ b/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py @@ -1,4 +1,4 @@ -"""Add a numerical index to sort header matches. +"""Add a numerical position column to sort header matches. Revision ID: d4fbb4fd34ca Revises: bfda02ab3a9b @@ -16,25 +16,22 @@ from mailman.database.helpers import is_sqlite def upgrade(): - op.add_column( - 'headermatch', sa.Column('index', sa.Integer(), nullable=True)) - if not is_sqlite(op.get_bind()): - op.alter_column( - 'headermatch', 'mailing_list_id', - existing_type=sa.INTEGER(), nullable=False) - op.create_index( - op.f('ix_headermatch_index'), 'headermatch', ['index'], unique=False) - op.create_index( - op.f('ix_headermatch_mailing_list_id'), 'headermatch', - ['mailing_list_id'], unique=False) + with op.batch_alter_table('headermatch') as batch_op: + batch_op.add_column( + sa.Column('position', sa.Integer(), nullable=True)) + batch_op.alter_column( + 'mailing_list_id', existing_type=sa.INTEGER(), nullable=False) + batch_op.create_index( + op.f('ix_headermatch_position'), ['position'], unique=False) + batch_op.create_index( + op.f('ix_headermatch_mailing_list_id'), ['mailing_list_id'], + unique=False) def downgrade(): - op.drop_index( - op.f('ix_headermatch_mailing_list_id'), table_name='headermatch') - op.drop_index(op.f('ix_headermatch_index'), table_name='headermatch') - if not is_sqlite(op.get_bind()): - op.alter_column( - 'headermatch', 'mailing_list_id', - existing_type=sa.INTEGER(), nullable=True) - op.drop_column('headermatch', 'index') + with op.batch_alter_table('headermatch') as batch_op: + batch_op.drop_index(op.f('ix_headermatch_mailing_list_id')) + batch_op.drop_index(op.f('ix_headermatch_position')) + batch_op.alter_column( + 'mailing_list_id', existing_type=sa.INTEGER(), nullable=True) + batch_op.drop_column('position') |
