"""Update uniqueness constraint name for users.alternative_id

Revision ID: 8ffe4640e009
Revises: ef1936dcc5eb
Create Date: 2024-02-09 18:23:45.140756

"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "8ffe4640e009"
down_revision = "ef1936dcc5eb"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("legacy_users", schema=None) as batch_op:
        batch_op.drop_constraint("uq_users_alternative_id", type_="unique")
        batch_op.create_unique_constraint(
            batch_op.f("uq_legacy_users_alternative_id"), ["alternative_id"]
        )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("legacy_users", schema=None) as batch_op:
        batch_op.drop_constraint(
            batch_op.f("uq_legacy_users_alternative_id"), type_="unique"
        )
        batch_op.create_unique_constraint("uq_users_alternative_id", ["alternative_id"])

    # ### end Alembic commands ###
