"""drop tag_eval_run — the head-vs-centroid eval harness is retired

The eval (#1130) existed to prove the heads tagging spine on the operator's own
data. It did; the operator accepted the system and retired the harness
(2026-07-02) — card, API, task, model and this table all go. The eval's data
loaders + metric helpers live on in services/ml/training_data.py, where the
production heads trainer uses them nightly.

Revision ID: 0073
Revises: 0072
Create Date: 2026-07-02
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

revision: str = "0073"
down_revision: Union[str, None] = "0072"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.drop_index("ix_tag_eval_run_status", table_name="tag_eval_run")
    op.drop_table("tag_eval_run")


def downgrade() -> None:
    # Recreates the shape from 0056 (data is not restorable).
    op.create_table(
        "tag_eval_run",
        sa.Column("id", sa.Integer(), primary_key=True),
        sa.Column("params", postgresql.JSONB(), nullable=False),
        sa.Column("status", sa.String(length=16), nullable=False,
                  server_default="running"),
        sa.Column("started_at", sa.DateTime(timezone=True), nullable=False,
                  server_default=sa.func.now()),
        sa.Column("finished_at", sa.DateTime(timezone=True), nullable=True),
        sa.Column("report", postgresql.JSONB(), nullable=True),
        sa.Column("error", sa.Text(), nullable=True),
        sa.Column("last_progress_at", sa.DateTime(timezone=True),
                  nullable=True),
    )
    op.create_index("ix_tag_eval_run_status", "tag_eval_run", ["status"])
