"""Add (repo_id, blast DESC) index on musehub_symbol_intel for blast-leader card query. The DISTINCT ON (repo_id) ORDER BY repo_id, blast DESC query used by enrich_repo_cards() needs this index to avoid a sequential scan when fetching the top blast symbol per repo across a batch of repo IDs. Revision ID: 0033 Revises: 0032 """ from __future__ import annotations from alembic import op import sqlalchemy as sa revision = "0033" down_revision = "0032" branch_labels = None depends_on = None def upgrade() -> None: op.create_index( "ix_symbol_intel_repo_blast", "musehub_symbol_intel", ["repo_id", sa.text("blast DESC NULLS LAST")], if_not_exists=True, ) def downgrade() -> None: op.drop_index("ix_symbol_intel_repo_blast", table_name="musehub_symbol_intel")