"""Add case assignee

Revision ID: 0b9bf4cd7276
Revises: 61f47f34caa9
Create Date: 2025-05-03 16:22:02.628112

"""

from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "0b9bf4cd7276"
down_revision: str | None = "61f47f34caa9"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None

fk_case_assignee_id = "fk_case_assignee_id"


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("cases", sa.Column("assignee_id", sa.UUID(), nullable=True))
    op.create_foreign_key(
        fk_case_assignee_id,
        "cases",
        "user",
        ["assignee_id"],
        ["id"],
        ondelete="SET NULL",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(fk_case_assignee_id, "cases", type_="foreignkey")
    op.drop_column("cases", "assignee_id")
    # ### end Alembic commands ###
