"""phase0 SR-006 — campaign_tests composite index

Most SR-006 indexes already ship in b005, b009, b018, b019, and b026.
``tests`` has no ``campaign_id`` column (membership is ``campaign_tests``),
so this revision adds a composite index to speed “tests in campaign” joins.

Revision ID: b028phase0
Revises: b027scorecfg
Create Date: 2026-05-18 12:00:00.000000

"""
from typing import Sequence, Union

from alembic import op

revision: str = "b028phase0"
down_revision: Union[str, None] = "b027scorecfg"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_index(
        "ix_campaign_tests_campaign_id_test_id",
        "campaign_tests",
        ["campaign_id", "test_id"],
        unique=False,
    )


def downgrade() -> None:
    op.drop_index(
        "ix_campaign_tests_campaign_id_test_id",
        table_name="campaign_tests",
    )
