Blame alembic/versions/47f5fab6f46a_private_pull_request.py

Pierre-Yves Chibon 1ab575
"""private pull-request
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
Revision ID: 47f5fab6f46a
Pierre-Yves Chibon 1ab575
Revises: a13967424130
Pierre-Yves Chibon 1ab575
Create Date: 2017-11-06 11:37:57.460886
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
"""
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
from alembic import op
Pierre-Yves Chibon 1ab575
import sqlalchemy as sa
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
# revision identifiers, used by Alembic.
Pierre-Yves Chibon 1ab575
revision = '47f5fab6f46a'
Pierre-Yves Chibon 1ab575
down_revision = 'a13967424130'
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
def upgrade():
Pierre-Yves Chibon 1ab575
    ''' Add a private column in the pull_requests table
Pierre-Yves Chibon 1ab575
    '''
Pierre-Yves Chibon 1ab575
    op.add_column(
Pierre-Yves Chibon 1ab575
        'pull_requests',
Pierre-Yves Chibon 1ab575
        sa.Column('private', sa.Boolean, nullable=True, default=False)
Pierre-Yves Chibon 1ab575
    )
Pierre-Yves Chibon 1ab575
    op.execute('''UPDATE "pull_requests" '''
Pierre-Yves Chibon 1ab575
               '''SET private=False;''')
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
    op.alter_column(
Pierre-Yves Chibon 1ab575
        'pull_requests',
Pierre-Yves Chibon 1ab575
        column_name='private',
Pierre-Yves Chibon 1ab575
        nullable=False, existing_nullable=True)
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
Pierre-Yves Chibon 1ab575
def downgrade():
Pierre-Yves Chibon 1ab575
    ''' Remove the private column
Pierre-Yves Chibon 1ab575
    '''
Pierre-Yves Chibon 1ab575
    op.drop_column('pull_requests', 'private')