"""fix document unique key

Revision ID: 7cfa662dff86
Revises: 9f486f3bf6ac
Create Date: 2024-06-24 14:36:18.455799

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "7cfa662dff86"
down_revision: Union[str, None] = "9f486f3bf6ac"
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("uq_document_uuid_base_url", "document", type_="unique")
    op.create_unique_constraint(
        "uq_document_uuid_base_url_filename",
        "document",
        ["uuid", "base_uri", "filename"],
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("uq_document_uuid_base_url_filename", "document", type_="unique")
    op.create_unique_constraint(
        "uq_document_uuid_base_url", "document", ["uuid", "base_uri"]
    )
    # ### end Alembic commands ###
