Blame alembic/versions/46df6466b8fa_drop_pull_request_check.py
|
Pierre-Yves Chibon |
310593 |
"""drop pull_request_check
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
Revision ID: 46df6466b8fa
|
|
Pierre-Yves Chibon |
310593 |
Revises: 61ac23e35f86
|
|
Pierre-Yves Chibon |
310593 |
Create Date: 2017-12-18 12:37:44.833468
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
"""
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
310593 |
revision = '46df6466b8fa'
|
|
Pierre-Yves Chibon |
310593 |
down_revision = '61ac23e35f86'
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
from alembic import op
|
|
Pierre-Yves Chibon |
310593 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
def upgrade():
|
|
Pierre-Yves Chibon |
310593 |
""" Drop the pull_request_check constraint. """
|
|
Pierre-Yves Chibon |
310593 |
connection = op.get_bind()
|
|
Pierre-Yves Chibon |
310593 |
connection.begin_nested()
|
|
Pierre-Yves Chibon |
310593 |
try:
|
|
Pierre-Yves Chibon |
310593 |
op.drop_constraint("pull_requests_check", "pull_requests")
|
|
Pierre-Yves Chibon |
310593 |
except sa.exc.ProgrammingError:
|
|
Pierre-Yves Chibon |
310593 |
connection.connection.connection.rollback()
|
|
Pierre-Yves Chibon |
310593 |
print(
|
|
Pierre-Yves Chibon |
310593 |
'Ignoring the pull_requests_check '
|
|
Pierre-Yves Chibon |
310593 |
'constraint if it does not exist')
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
|
|
Pierre-Yves Chibon |
310593 |
def downgrade():
|
|
Pierre-Yves Chibon |
310593 |
""" Bring back the pull_request_check constraint. """
|
|
Pierre-Yves Chibon |
310593 |
op.create_check_constraint(
|
|
Pierre-Yves Chibon |
310593 |
"pull_requests_check",
|
|
Pierre-Yves Chibon |
310593 |
"pull_requests",
|
|
Pierre-Yves Chibon |
310593 |
'NOT(project_id_from IS NULL AND remote_git IS NULL)'
|
|
Pierre-Yves Chibon |
310593 |
)
|