blob: 66ffb0169b3f8172eaff56f28b8946c68a295b60 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
"""Add a numerical position column to sort header matches.
Revision ID: d4fbb4fd34ca
Revises: bfda02ab3a9b
Create Date: 2016-02-01 15:57:09.807678
"""
# revision identifiers, used by Alembic.
revision = 'd4fbb4fd34ca'
down_revision = 'bfda02ab3a9b'
import sqlalchemy as sa
from alembic import op
def upgrade():
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():
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')
|