"""replace invitation email index with workspace email unique constraint

Revision ID: 49a5c7464ab7
Revises: b22e78f9a6bc
Create Date: 2026-01-23 11:32:02.933587

"""

from collections.abc import Sequence

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "49a5c7464ab7"
down_revision: str | None = "b22e78f9a6bc"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_invitation_email", table_name="invitation")
    op.create_unique_constraint(
        op.f("uq_invitation_workspace_id_email"),
        "invitation",
        ["workspace_id", "email"],
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("uq_invitation_workspace_id_email"), "invitation", type_="unique"
    )
    op.create_index("ix_invitation_email", "invitation", ["email"], unique=False)
    # ### end Alembic commands ###
