Digitale bierlijst

6a5989118ee3_enable_unique_constraints.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """Enable unique constraints
  2. Revision ID: 6a5989118ee3
  3. Revises: cca57457a0a6
  4. Create Date: 2019-09-22 17:04:01.945713
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = "6a5989118ee3"
  10. down_revision = "cca57457a0a6"
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. with op.batch_alter_table("consumption_types") as batch_op:
  15. batch_op.create_unique_constraint("uc_consumption_types_name", ["name"])
  16. with op.batch_alter_table("people") as batch_op2:
  17. batch_op2.create_unique_constraint("uc_people_aardbei_id", ["aardbei_id"])
  18. batch_op2.create_unique_constraint("uc_people_full_name", ["full_name"])
  19. batch_op2.create_unique_constraint("uc_people_display_name", ["display_name"])
  20. def downgrade():
  21. with op.batch_alter_table("people") as batch_op2:
  22. batch_op2.drop_constraint("uc_people_display_name", type_="unique")
  23. batch_op2.drop_constraint("uc_people_full_name", type_="unique")
  24. batch_op2.drop_constraint("uc_people_aardbei_id", type_="unique")
  25. with op.batch_alter_table("consumption_types") as batch_op:
  26. batch_op.drop_constraint("uc_consumption_types_name", type_="unique")