From 743f425d5f2b0623df6fa970f5ba08c2341d0ebd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 06 2017 16:35:22 +0000 Subject: Rename and adjust the alembic migration script adding key_notify --- diff --git a/alembic/versions/11470abae0d6_.py b/alembic/versions/11470abae0d6_.py deleted file mode 100644 index d5d8691..0000000 --- a/alembic/versions/11470abae0d6_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""empty message - -Revision ID: 11470abae0d6 -Revises: 987edda096f5 -Create Date: 2017-03-04 10:19:14.842910 - -""" - -# revision identifiers, used by Alembic. -revision = '11470abae0d6' -down_revision = '987edda096f5' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ''' Add a column to record if the custom field should trigger a email - notification. - ''' - op.add_column( - 'issue_keys', - sa.Column('key_notify', sa.Boolean, default=False, nullable=False) - ) - - -def downgrade(): - ''' Remove the key_notify column. - ''' - op.drop_column('issue_keys', 'key_notify') diff --git a/alembic/versions/11470abae0d6_add_key_notify_to_issue_keys.py b/alembic/versions/11470abae0d6_add_key_notify_to_issue_keys.py new file mode 100644 index 0000000..4b2e763 --- /dev/null +++ b/alembic/versions/11470abae0d6_add_key_notify_to_issue_keys.py @@ -0,0 +1,36 @@ +"""Add key_notify to the issues_keys table + +Revision ID: 11470abae0d6 +Revises: 987edda096f5 +Create Date: 2017-03-04 10:19:14.842910 + +""" + +# revision identifiers, used by Alembic. +revision = '11470abae0d6' +down_revision = '987edda096f5' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ''' Add a column to record if the custom field should trigger a email + notification. + ''' + op.add_column( + 'issue_keys', + sa.Column( + 'key_notify', sa.Boolean, default=False, nullable=True + ) + ) + op.execute('UPDATE issue_keys SET key_notify=False') + op.alter_column( + 'issue_keys', 'key_notify', + nullable=False, existing_nullable=True) + + +def downgrade(): + ''' Remove the key_notify column. + ''' + op.drop_column('issue_keys', 'key_notify')