"""remove score range from llm evals

Revision ID: 5d30b8ab358b
Revises: 4392c0a6800e
Create Date: 2025-11-15 16:18:53.418393

"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "5d30b8ab358b"
down_revision = "4392c0a6800e"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("llm_evals", "max_score")
    op.drop_column("llm_evals", "min_score")
    # ### end Alembic commands ###


def downgrade() -> None:
    # 1. Add nullable columns
    op.add_column(
        "llm_evals",
        sa.Column("min_score", sa.INTEGER(), nullable=True),
    )
    op.add_column(
        "llm_evals",
        sa.Column("max_score", sa.INTEGER(), nullable=True),
    )

    # 2. Backfill defaults
    op.execute("UPDATE llm_evals SET min_score = 0 WHERE min_score IS NULL;")
    op.execute("UPDATE llm_evals SET max_score = 1 WHERE max_score IS NULL;")

    # 3. Make them NOT NULL
    op.alter_column("llm_evals", "min_score", nullable=False)
    op.alter_column("llm_evals", "max_score", nullable=False)
