"""Add Payment.wallet_id

Revision ID: 8a77908046f4
Revises: 6845646317f9
Create Date: 2025-10-28 11:19:18.795705

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "8a77908046f4"
down_revision = "6845646317f9"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("payments", sa.Column("wallet_id", sa.Uuid(), nullable=True))
    op.create_index(
        op.f("ix_payments_wallet_id"), "payments", ["wallet_id"], unique=False
    )
    op.create_foreign_key(
        op.f("payments_wallet_id_fkey"),
        "payments",
        "wallets",
        ["wallet_id"],
        ["id"],
        ondelete="set null",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f("payments_wallet_id_fkey"), "payments", type_="foreignkey")
    op.drop_index(op.f("ix_payments_wallet_id"), table_name="payments")
    op.drop_column("payments", "wallet_id")
    # ### end Alembic commands ###
