Blame alembic/versions/4255158a6913_create_private_column_in_project_table.py

farhaanbukhsh b25a08
"""Create private column in project table
farhaanbukhsh b25a08
farhaanbukhsh b25a08
Revision ID: 4255158a6913
farhaanbukhsh b25a08
Revises: 317a285e04a8
farhaanbukhsh b25a08
Create Date: 2016-06-06 14:33:47.039207
farhaanbukhsh b25a08
farhaanbukhsh b25a08
"""
farhaanbukhsh b25a08
farhaanbukhsh b25a08
# revision identifiers, used by Alembic.
farhaanbukhsh b25a08
revision = '4255158a6913'
farhaanbukhsh b25a08
down_revision = '317a285e04a8'
farhaanbukhsh b25a08
farhaanbukhsh b25a08
from alembic import op
farhaanbukhsh b25a08
import sqlalchemy as sa
farhaanbukhsh b25a08
farhaanbukhsh b25a08
farhaanbukhsh b25a08
def upgrade():
farhaanbukhsh b25a08
    ''' Add a pivate column in the project table
farhaanbukhsh b25a08
    '''
farhaanbukhsh b25a08
    op.add_column(
farhaanbukhsh b25a08
        'projects',
farhaanbukhsh 491820
        sa.Column('_private', sa.Boolean, nullable=True, default=False)
farhaanbukhsh b25a08
    )
farhaanbukhsh 491820
    op.execute('''UPDATE "projects" '''
farhaanbukhsh 491820
               '''SET _private=False;''')
farhaanbukhsh b25a08
farhaanbukhsh 491820
    op.alter_column(
farhaanbukhsh 491820
        'projects',
farhaanbukhsh 491820
        column_name='_private', new_column_name='private',
farhaanbukhsh 491820
        nullable=False, existing_nullable=True)
farhaanbukhsh b25a08
farhaanbukhsh b25a08
farhaanbukhsh b25a08
def downgrade():
farhaanbukhsh b25a08
    ''' Remove the private column
farhaanbukhsh b25a08
    '''
farhaanbukhsh b25a08
    op.drop_column('projects', 'private')