Blame alembic/versions/257a7ce22682_add_the_remote_git_entry.py
|
Pierre-Yves Chibon |
b9ffc4 |
"""Add the remote_git entry
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
Revision ID: 257a7ce22682
|
|
Pierre-Yves Chibon |
b9ffc4 |
Revises: 36116bb7a69b
|
|
Pierre-Yves Chibon |
b9ffc4 |
Create Date: 2015-07-21 14:26:23.989220
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
"""
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
b9ffc4 |
revision = '257a7ce22682'
|
|
Pierre-Yves Chibon |
b9ffc4 |
down_revision = '36116bb7a69b'
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
from alembic import op
|
|
Pierre-Yves Chibon |
b9ffc4 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
def upgrade():
|
|
Pierre-Yves Chibon |
b9ffc4 |
''' Add the column remote_git to the table pull_requests and make the
|
|
Pierre-Yves Chibon |
b9ffc4 |
project_id_from field nullable.
|
|
Pierre-Yves Chibon |
b9ffc4 |
'''
|
|
Pierre-Yves Chibon |
b9ffc4 |
op.add_column(
|
|
Pierre-Yves Chibon |
b9ffc4 |
'pull_requests',
|
|
Pierre-Yves Chibon |
b9ffc4 |
sa.Column('remote_git', sa.Text, nullable=True)
|
|
Pierre-Yves Chibon |
b9ffc4 |
)
|
|
Pierre-Yves Chibon |
b9ffc4 |
op.alter_column(
|
|
Pierre-Yves Chibon |
b9ffc4 |
'pull_requests',
|
|
Pierre-Yves Chibon |
b9ffc4 |
column_name='project_id_from',
|
|
Pierre-Yves Chibon |
b9ffc4 |
nullable=True,
|
|
Pierre-Yves Chibon |
b9ffc4 |
existing_nullable=False)
|
|
Pierre-Yves Chibon |
5bbd80 |
op.create_check_constraint(
|
|
Pierre-Yves Chibon |
5bbd80 |
"ck_lcl_or_remo_pr",
|
|
Pierre-Yves Chibon |
5bbd80 |
"pull_requests",
|
|
Pierre-Yves Chibon |
5bbd80 |
'NOT(project_id_from IS NULL AND remote_git IS NULL)'
|
|
Pierre-Yves Chibon |
5bbd80 |
)
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
|
|
Pierre-Yves Chibon |
b9ffc4 |
def downgrade():
|
|
Pierre-Yves Chibon |
b9ffc4 |
''' Remove the column remote_git from the table pull_requests and make
|
|
Pierre-Yves Chibon |
b9ffc4 |
the project_id_from field not nullable.
|
|
Pierre-Yves Chibon |
b9ffc4 |
'''
|
|
Pierre-Yves Chibon |
b9ffc4 |
op.drop_column('pull_requests', 'remote_git')
|
|
Pierre-Yves Chibon |
b9ffc4 |
op.alter_column(
|
|
Pierre-Yves Chibon |
b9ffc4 |
'pull_requests',
|
|
Pierre-Yves Chibon |
b9ffc4 |
column_name='project_id_from',
|
|
Pierre-Yves Chibon |
b9ffc4 |
nullable=False,
|
|
Pierre-Yves Chibon |
b9ffc4 |
existing_nullable=True)
|