01e58ee9eccb_adjust_constraints_on_pull_request_flags.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """Adjust constraints on pull_request_flags
  2. Revision ID: 01e58ee9eccb
  3. Revises: 6119fbbcc8e9
  4. Create Date: 2017-11-16 16:50:47.278252
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '01e58ee9eccb'
  10. down_revision = '6119fbbcc8e9'
  11. def upgrade():
  12. """ Remove the unique constraints on UID in pull_request_flags and make
  13. it a composite unique constraint on UID + pull_request_uid.
  14. """
  15. # alter the constraints
  16. op.drop_constraint('pull_request_flags_uid_key', 'pull_request_flags')
  17. op.create_unique_constraint(
  18. "pull_request_flags_uid_pull_request_uid_key",
  19. 'pull_request_flags',
  20. ["uid", "pull_request_uid"]
  21. )
  22. def downgrade():
  23. """ Remove the composite unique constraints on UID + pull_request_uid
  24. in pull_request_flags and make it an unique constraint on UID .
  25. """
  26. op.drop_constraint(
  27. 'pull_request_flags_uid_pull_request_uid_key',
  28. 'pull_request_flags')
  29. op.create_unique_constraint(
  30. "pull_request_flags_uid_key",
  31. 'pull_request_flags',
  32. ["uid"]
  33. )