"""llm_calls_cascade_fk

Revision ID: 40f43097368d
Revises: 20260309_000001
Create Date: 2026-03-09 23:50:59.402007
"""

from alembic import op


# revision identifiers, used by Alembic.
revision = "40f43097368d"
down_revision = "20260309_000001"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f("llm_calls_agent_id_fkey"), "llm_calls", type_="foreignkey")
    op.drop_constraint(op.f("llm_calls_run_id_fkey"), "llm_calls", type_="foreignkey")
    op.create_foreign_key(
        None, "llm_calls", "simulation_runs", ["run_id"], ["id"], ondelete="CASCADE"
    )
    op.create_foreign_key(None, "llm_calls", "agents", ["agent_id"], ["id"], ondelete="SET NULL")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "llm_calls", type_="foreignkey")
    op.drop_constraint(None, "llm_calls", type_="foreignkey")
    op.create_foreign_key(
        op.f("llm_calls_run_id_fkey"), "llm_calls", "simulation_runs", ["run_id"], ["id"]
    )
    op.create_foreign_key(
        op.f("llm_calls_agent_id_fkey"), "llm_calls", "agents", ["agent_id"], ["id"]
    )
    # ### end Alembic commands ###
