"""Add Payout unique constraint

Revision ID: a8b767b4a34a
Revises: c61bb7759df7
Create Date: 2025-06-05 08:31:16.946896

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "a8b767b4a34a"
down_revision = "c61bb7759df7"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_payouts_account_id", table_name="payouts")
    op.create_unique_constraint(
        op.f("payouts_account_id_invoice_number_key"),
        "payouts",
        ["account_id", "invoice_number"],
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("payouts_account_id_invoice_number_key"), "payouts", type_="unique"
    )
    op.create_index("ix_payouts_account_id", "payouts", ["account_id"], unique=False)
    # ### end Alembic commands ###
