"""add confidence_score/data_quality_score columns to scores

Revision ID: 0002
Revises: 0001
Create Date: 2026-09-08

StockLab overhaul, Part A1 — end-to-end wiring of `compute_confidence_score()`/
`compute_data_quality_score()` (docs/FINAL_REPORT.md §7's "Score/Confidence/Data Quality wiring
gap" finding). Purely additive: 4 new nullable columns on `scores`, no existing column touched, no
backfill required (existing rows simply have these as NULL/None until their next recompute) — in
line with docs/DEPLOYMENT.md §5's "additive where possible" migration policy, so this ships as a
single deploy rather than the add-then-backfill-then-drop dance a destructive change would need.

NOT RUN in the build environment this migration was authored in — `alembic`/`sqlalchemy` are not
installed there (no network access to install them; see docs/TEST_REPORT.md §2/§6). Verified with
`python3 -m py_compile` only. Run `alembic upgrade head` against a real Postgres instance and
confirm the resulting column set matches `app/models/derived.py::Score` before trusting this file
in production, per the same disclosure given for 0001_initial_schema.py.
"""
from alembic import op
import sqlalchemy as sa

revision = "0002"
down_revision = "0001"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("scores", sa.Column("confidence_score", sa.Float, nullable=True))
    op.add_column("scores", sa.Column("confidence_components", sa.JSON, nullable=True))
    op.add_column("scores", sa.Column("data_quality_score", sa.Float, nullable=True))
    op.add_column("scores", sa.Column("data_quality_components", sa.JSON, nullable=True))


def downgrade() -> None:
    op.drop_column("scores", "data_quality_components")
    op.drop_column("scores", "data_quality_score")
    op.drop_column("scores", "confidence_components")
    op.drop_column("scores", "confidence_score")
