"""Add agent_preset_id to chat

Revision ID: fba6c5cd4c77
Revises: d110a55643ba
Create Date: 2025-11-05 12:34:56.000000

"""

from collections.abc import Sequence

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "fba6c5cd4c77"
down_revision: str | None = "d110a55643ba"
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.add_column(
        "chat",
        sa.Column("agent_preset_id", postgresql.UUID(as_uuid=True), nullable=True),
    )
    op.create_foreign_key(
        "fk_chat_agent_preset_id_agent_preset",
        "chat",
        "agent_preset",
        ["agent_preset_id"],
        ["id"],
        ondelete="SET NULL",
    )
    # ### end Alembic commands ###


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