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
Pierre-Yves Chibon 854b69
Revises: 4df75d40bafa
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'
Pierre-Yves Chibon 854b69
down_revision = '4df75d40bafa'
farhaanbukhsh b25a08
farhaanbukhsh b25a08
from alembic import op
farhaanbukhsh b25a08
import sqlalchemy as sa
farhaanbukhsh b25a08
farhaanbukhsh b25a08
farhaanbukhsh b25a08
def upgrade():
Farhaan Bukhsh 58dc47
    ''' Add a private column in the project table
farhaanbukhsh b25a08
    '''
farhaanbukhsh b25a08
    op.add_column(
farhaanbukhsh b25a08
        'projects',
Farhaan Bukhsh baa162
        sa.Column('private', sa.Boolean, nullable=True, default=False)
farhaanbukhsh b25a08
    )
farhaanbukhsh 491820
    op.execute('''UPDATE "projects" '''
Farhaan Bukhsh baa162
               '''SET private=False;''')
farhaanbukhsh b25a08
farhaanbukhsh 491820
    op.alter_column(
farhaanbukhsh 491820
        'projects',
Farhaan Bukhsh 8267d1
        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')