"""change documents url constraint to url_generation

Revision ID: 98d24c27bbe3
Revises: 40de6c7e554f
Create Date: 2025-12-02 09:31:31.658550
"""

from typing import Sequence, Union

from alembic import op


# revision identifiers, used by Alembic.
revision: str = "98d24c27bbe3"
down_revision: Union[str, None] = "40de6c7e554f"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f("documents_url_key"), "documents", type_="unique")
    op.create_unique_constraint("documents_url_generation_key", "documents", ["url", "generation_id"])
    op.create_index(op.f("ix_documents_url"), "documents", ["url"], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_documents_url"), table_name="documents")
    op.drop_constraint("documents_url_generation_key", "documents", type_="unique")
    op.create_unique_constraint(op.f("documents_url_key"), "documents", ["url"], postgresql_nulls_not_distinct=False)
    # ### end Alembic commands ###
