"""Makes various unique constraint's unique on a per-project basis.

Revision ID: 87400096f4cc
Revises: fb5639709294
Create Date: 2021-04-20 09:53:04.017963

"""
from alembic import op


# revision identifiers, used by Alembic.
revision = "87400096f4cc"
down_revision = "fb5639709294"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("definition_text_key", "definition", type_="unique")
    op.create_unique_constraint(None, "definition", ["text", "project_id"])
    op.drop_constraint("incident_priority_name_key", "incident_priority", type_="unique")
    op.create_unique_constraint(None, "incident_priority", ["name", "project_id"])
    op.drop_constraint("incident_type_name_key", "incident_type", type_="unique")
    op.create_unique_constraint(None, "incident_type", ["name", "project_id"])
    op.drop_constraint("individual_contact_email_key", "individual_contact", type_="unique")
    op.create_unique_constraint(None, "individual_contact", ["email", "project_id"])
    op.drop_constraint("search_filter_name_key", "search_filter", type_="unique")
    op.create_unique_constraint(None, "search_filter", ["name", "project_id"])
    op.drop_constraint("tag_name_key", "tag", type_="unique")
    op.create_unique_constraint(None, "tag", ["name", "project_id"])
    op.drop_constraint("tag_type_name_key", "tag_type", type_="unique")
    op.create_unique_constraint(None, "tag_type", ["name", "project_id"])
    op.drop_constraint("team_contact_email_key", "team_contact", type_="unique")
    op.create_unique_constraint(None, "team_contact", ["email", "project_id"])
    op.drop_constraint("term_text_key", "term", type_="unique")
    op.create_unique_constraint(None, "term", ["text", "project_id"])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "term", type_="unique")
    op.create_unique_constraint("term_text_key", "term", ["text"])
    op.drop_constraint(None, "team_contact", type_="unique")
    op.create_unique_constraint("team_contact_email_key", "team_contact", ["email"])
    op.drop_constraint(None, "tag_type", type_="unique")
    op.create_unique_constraint("tag_type_name_key", "tag_type", ["name"])
    op.drop_constraint(None, "tag", type_="unique")
    op.create_unique_constraint("tag_name_key", "tag", ["name"])
    op.drop_constraint(None, "search_filter", type_="unique")
    op.create_unique_constraint("search_filter_name_key", "search_filter", ["name"])
    op.drop_constraint(None, "individual_contact", type_="unique")
    op.create_unique_constraint("individual_contact_email_key", "individual_contact", ["email"])
    op.drop_constraint(None, "incident_type", type_="unique")
    op.create_unique_constraint("incident_type_name_key", "incident_type", ["name"])
    op.drop_constraint(None, "incident_priority", type_="unique")
    op.create_unique_constraint("incident_priority_name_key", "incident_priority", ["name"])
    op.drop_constraint(None, "definition", type_="unique")
    op.create_unique_constraint("definition_text_key", "definition", ["text"])
    # ### end Alembic commands ###
