"""Set Transaction.account_id ON DELETE RESTRICT

Revision ID: 65aeef3d240b
Revises: 78b2c37d5aa0
Create Date: 2025-03-17 09:45:12.204242

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "65aeef3d240b"
down_revision = "78b2c37d5aa0"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        "transactions_account_id_fkey", "transactions", type_="foreignkey"
    )
    op.create_foreign_key(
        op.f("transactions_account_id_fkey"),
        "transactions",
        "accounts",
        ["account_id"],
        ["id"],
        ondelete="restrict",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("transactions_account_id_fkey"), "transactions", type_="foreignkey"
    )
    op.create_foreign_key(
        "transactions_account_id_fkey",
        "transactions",
        "accounts",
        ["account_id"],
        ["id"],
        ondelete="SET NULL",
    )
    # ### end Alembic commands ###
