diff options
| author | Aurélien Bompard | 2016-02-29 11:59:29 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2016-02-29 21:52:13 -0500 |
| commit | 567aab277deaba88329aa25a0d1f2a8959522071 (patch) | |
| tree | 80159f40e0fc4175da03f26f97f3f5ff84567406 /src/mailman/database | |
| parent | 65459448ee6da85878159e0ad1c8f556c1bd617e (diff) | |
| download | mailman-567aab277deaba88329aa25a0d1f2a8959522071.tar.gz mailman-567aab277deaba88329aa25a0d1f2a8959522071.tar.zst mailman-567aab277deaba88329aa25a0d1f2a8959522071.zip | |
Review suggestions: rename the new index column to position
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') |
