"""Add one index

Revision ID: 49b4ad646404
Revises: 7317838df672
Create Date: 2025-11-27 15:54:11.956077

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "49b4ad646404"
down_revision = "7317838df672"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.get_context().autocommit_block():
        op.create_index(
            "ix_events_organization_external_id_ingested_at_desc",
            "events",
            [
                "organization_id",
                "external_customer_id",
                sa.literal_column("ingested_at DESC"),
            ],
            unique=False,
            postgresql_concurrently=True,
        )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        "ix_events_organization_external_id_ingested_at_desc", table_name="events"
    )
    # ### end Alembic commands ###
