46df6466b8fa_drop_pull_request_check.py 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. """drop pull_request_check
  2. Revision ID: 46df6466b8fa
  3. Revises: 61ac23e35f86
  4. Create Date: 2017-12-18 12:37:44.833468
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '46df6466b8fa'
  8. down_revision = '61ac23e35f86'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. """ Drop the pull_request_check constraint. """
  13. connection = op.get_bind()
  14. connection.begin_nested()
  15. try:
  16. op.drop_constraint("pull_requests_check", "pull_requests")
  17. except sa.exc.ProgrammingError:
  18. connection.connection.connection.rollback()
  19. print(
  20. 'Ignoring the pull_requests_check '
  21. 'constraint if it does not exist')
  22. def downgrade():
  23. """ Bring back the pull_request_check constraint. """
  24. op.create_check_constraint(
  25. "pull_requests_check",
  26. "pull_requests",
  27. 'NOT(project_id_from IS NULL AND remote_git IS NULL)'
  28. )