|
Pierre-Yves Chibon |
5e7392 |
"""Change the status of pull_requests
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
Revision ID: 298891e63039
|
|
Pierre-Yves Chibon |
5e7392 |
Revises: 3c25e14b855b
|
|
Pierre-Yves Chibon |
5e7392 |
Create Date: 2015-06-08 13:06:11.938966
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
"""
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
5e7392 |
revision = '298891e63039'
|
|
Pierre-Yves Chibon |
5e7392 |
down_revision = '3c25e14b855b'
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
from alembic import op
|
|
Pierre-Yves Chibon |
5e7392 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
def upgrade():
|
|
Pierre-Yves Chibon |
5e7392 |
''' Adjust the status column of the pull_requests table.
|
|
Pierre-Yves Chibon |
5e7392 |
'''
|
|
Pierre-Yves Chibon |
5e7392 |
op.add_column(
|
|
Pierre-Yves Chibon |
5e7392 |
'pull_requests',
|
|
Pierre-Yves Chibon |
5e7392 |
sa.Column(
|
|
Pierre-Yves Chibon |
5e7392 |
'_status', sa.Text,
|
|
Pierre-Yves Chibon |
5e7392 |
sa.ForeignKey(
|
|
Pierre-Yves Chibon |
5e7392 |
'status_pull_requests.status', onupdate='CASCADE'),
|
|
Pierre-Yves Chibon |
5e7392 |
default='Open',
|
|
Pierre-Yves Chibon |
5e7392 |
nullable=True)
|
|
Pierre-Yves Chibon |
5e7392 |
)
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
op.execute('''UPDATE "pull_requests" '''
|
|
Pierre-Yves Chibon |
5e7392 |
'''SET _status='Open' WHERE status=TRUE;''')
|
|
Pierre-Yves Chibon |
5e7392 |
op.execute('''UPDATE "pull_requests" '''
|
|
Pierre-Yves Chibon |
5e7392 |
'''SET _status='Merged' WHERE status=FALSE;''')
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
op.drop_column('pull_requests', 'status')
|
|
Pierre-Yves Chibon |
5e7392 |
op.alter_column(
|
|
Pierre-Yves Chibon |
5e7392 |
'pull_requests',
|
|
Pierre-Yves Chibon |
5e7392 |
column_name='_status', new_column_name='status',
|
|
Pierre-Yves Chibon |
5e7392 |
nullable=False, existing_nullable=True)
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
def downgrade():
|
|
Pierre-Yves Chibon |
5e7392 |
''' Revert the status column of the pull_requests table.
|
|
Pierre-Yves Chibon |
5e7392 |
'''
|
|
Pierre-Yves Chibon |
5e7392 |
op.add_column(
|
|
Pierre-Yves Chibon |
5e7392 |
'pull_requests',
|
|
Pierre-Yves Chibon |
5e7392 |
sa.Column(
|
|
Pierre-Yves Chibon |
5e7392 |
'_status', sa.Boolean, default=True, nullable=True)
|
|
Pierre-Yves Chibon |
5e7392 |
)
|
|
Pierre-Yves Chibon |
5e7392 |
op.execute('''UPDATE "pull_requests" '''
|
|
Pierre-Yves Chibon |
5e7392 |
'''SET _status=TRUE WHERE status='Open';''')
|
|
Pierre-Yves Chibon |
5e7392 |
op.execute('''UPDATE "pull_requests" '''
|
|
Pierre-Yves Chibon |
5e7392 |
'''SET _status=FALSE WHERE status!='Open';''')
|
|
Pierre-Yves Chibon |
5e7392 |
|
|
Pierre-Yves Chibon |
5e7392 |
op.drop_column('pull_requests', 'status')
|
|
Pierre-Yves Chibon |
5e7392 |
op.alter_column(
|
|
Pierre-Yves Chibon |
5e7392 |
'pull_requests',
|
|
Pierre-Yves Chibon |
5e7392 |
column_name='_status', new_column_name='status',
|
|
Pierre-Yves Chibon |
5e7392 |
nullable=False, existing_nullable=True)
|