"""add_indexes_drug_approvals_guideline_versions

Add missing indexes on linking columns to improve drug-guideline query performance.

Revision ID: 132de587a02d
Revises: 52946492580b
Create Date: 2026-07-16 13:19:20.144543
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa

revision: str = '132de587a02d'
down_revision: Union[str, None] = '52946492580b'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_index('ix_drug_approvals_cancer_type_tag_id', 'drug_approvals', ['cancer_type_tag_id'], unique=False)
    op.create_index('ix_drug_approvals_target', 'drug_approvals', ['target'], unique=False)
    op.create_index('ix_guideline_versions_cancer_type_tag_id', 'guideline_versions', ['cancer_type_tag_id'], unique=False)
    op.create_index('ix_guideline_versions_source_version', 'guideline_versions', ['guideline_source', 'version'], unique=False)


def downgrade() -> None:
    op.drop_index('ix_guideline_versions_source_version', table_name='guideline_versions')
    op.drop_index('ix_guideline_versions_cancer_type_tag_id', table_name='guideline_versions')
    op.drop_index('ix_drug_approvals_target', table_name='drug_approvals')
    op.drop_index('ix_drug_approvals_cancer_type_tag_id', table_name='drug_approvals')
