"""add_spend_visibility_option Revision ID: 7b65c710b258 Revises: 66b1d16db276 Create Date: 2021-03-15 12:20:13.561657 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '7b65c710b258' down_revision = '7f20f7366fb9' branch_labels = None depends_on = None def upgrade(): op.add_column('CampaignTypeValue', sa.Column('spend_visibility_option', sa.Integer(), nullable=True)) bind = op.get_bind() bind.execute(''' UPDATE "CampaignTypeValue" SET spend_visibility_option = 1 WHERE id IN (3, 6, 8, 9); UPDATE "CampaignTypeValue" SET spend_visibility_option = 2 WHERE id IN (2); UPDATE "CampaignTypeValue" SET spend_visibility_option = 0 WHERE id IN (1, 4, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25); ''') def downgrade(): op.drop_column('CampaignTypeValue', 'spend_visibility_option')