"""add momentum_percentile to trade_setups

The activation gate selects the top slice of the universe by 12-1 month momentum.
That rank is computed across all tickers at scan time and stored on each setup so
the live list, the Track Record's qualified stats, and outcome evaluation all gate
on the same value (momentum as of the setup's detection).

Revision ID: 010
Revises: 009
Create Date: 2026-06-23 00:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "010"
down_revision: Union[str, None] = "009"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "trade_setups",
        sa.Column("momentum_percentile", sa.Float(), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("trade_setups", "momentum_percentile")
