"""Add indices on hot foreign keys

Revision ID: 294d746cd4a8
Revises: 13c6e2052c0a
Create Date: 2025-04-30 15:33:59.789252

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "294d746cd4a8"
down_revision = "13c6e2052c0a"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        op.f("ix_benefits_organization_id"),
        "benefits",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_billing_entry_customer_id"),
        "billing_entry",
        ["customer_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_checkout_links_organization_id"),
        "checkout_links",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_custom_fields_organization_id"),
        "custom_fields",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_customer_session_codes_customer_id"),
        "customer_session_codes",
        ["customer_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_customer_sessions_customer_id"),
        "customer_sessions",
        ["customer_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_customers_organization_id"),
        "customers",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_discounts_organization_id"),
        "discounts",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_events_organization_id"), "events", ["organization_id"], unique=False
    )
    op.create_index(
        op.f("ix_issue_rewards_organization_id"),
        "issue_rewards",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_meters_organization_id"), "meters", ["organization_id"], unique=False
    )
    op.create_index(
        op.f("ix_notifications_organization_id"),
        "notifications",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_orders_customer_id"), "orders", ["customer_id"], unique=False
    )
    op.create_index(
        op.f("ix_organization_access_tokens_organization_id"),
        "organization_access_tokens",
        ["organization_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_product_prices_product_id"),
        "product_prices",
        ["product_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_products_organization_id"),
        "products",
        ["organization_id"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_products_organization_id"), table_name="products")
    op.drop_index(op.f("ix_product_prices_product_id"), table_name="product_prices")
    op.drop_index(
        op.f("ix_organization_access_tokens_organization_id"),
        table_name="organization_access_tokens",
    )
    op.drop_index(op.f("ix_orders_customer_id"), table_name="orders")
    op.drop_index(op.f("ix_notifications_organization_id"), table_name="notifications")
    op.drop_index(op.f("ix_meters_organization_id"), table_name="meters")
    op.drop_index(op.f("ix_issue_rewards_organization_id"), table_name="issue_rewards")
    op.drop_index(op.f("ix_events_organization_id"), table_name="events")
    op.drop_index(op.f("ix_discounts_organization_id"), table_name="discounts")
    op.drop_index(op.f("ix_customers_organization_id"), table_name="customers")
    op.drop_index(
        op.f("ix_customer_sessions_customer_id"), table_name="customer_sessions"
    )
    op.drop_index(
        op.f("ix_customer_session_codes_customer_id"),
        table_name="customer_session_codes",
    )
    op.drop_index(op.f("ix_custom_fields_organization_id"), table_name="custom_fields")
    op.drop_index(
        op.f("ix_checkout_links_organization_id"), table_name="checkout_links"
    )
    op.drop_index(op.f("ix_billing_entry_customer_id"), table_name="billing_entry")
    op.drop_index(op.f("ix_benefits_organization_id"), table_name="benefits")
    # ### end Alembic commands ###
