Blame alembic/versions/11470abae0d6_add_key_notify_to_issue_keys.py

Pierre-Yves Chibon 743f42
"""Add key_notify to the issues_keys table
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
Revision ID: 11470abae0d6
Mark Reynolds a8f1ac
Revises: 987edda096f5
Mark Reynolds a8f1ac
Create Date: 2017-03-04 10:19:14.842910
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
"""
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
# revision identifiers, used by Alembic.
Mark Reynolds a8f1ac
revision = '11470abae0d6'
Mark Reynolds a8f1ac
down_revision = '987edda096f5'
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
from alembic import op
Mark Reynolds a8f1ac
import sqlalchemy as sa
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
def upgrade():
Mark Reynolds a8f1ac
    ''' Add a column to record if the custom field should trigger a email
Mark Reynolds a8f1ac
    notification.
Mark Reynolds a8f1ac
    '''
Mark Reynolds a8f1ac
    op.add_column(
Mark Reynolds a8f1ac
        'issue_keys',
Pierre-Yves Chibon 743f42
        sa.Column(
Pierre-Yves Chibon 743f42
            'key_notify', sa.Boolean, default=False, nullable=True
Pierre-Yves Chibon 743f42
        )
Mark Reynolds a8f1ac
    )
Pierre-Yves Chibon 743f42
    op.execute('UPDATE issue_keys SET key_notify=False')
Pierre-Yves Chibon 743f42
    op.alter_column(
Pierre-Yves Chibon 743f42
        'issue_keys', 'key_notify',
Pierre-Yves Chibon 743f42
        nullable=False, existing_nullable=True)
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
Mark Reynolds a8f1ac
def downgrade():
Mark Reynolds a8f1ac
    ''' Remove the key_notify column.
Mark Reynolds a8f1ac
    '''
Mark Reynolds a8f1ac
    op.drop_column('issue_keys', 'key_notify')