"""Add estimation_report_json column to v3_plans.

Adds the ``estimation_report_json`` column to ``v3_plans`` to store the
full estimation report as a JSON-serialisable dict.  This column is
populated by the estimation actor lifecycle hook introduced in issue #651.

Revision ID: m6_006_estimation_report_json
Revises: m8_002_merge_profile_rename_and_corrections
Create Date: 2026-04-02 00:00:00

"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "m6_006_estimation_report_json"
down_revision: str | Sequence[str] | None = (
    "m8_002_merge_profile_rename_and_corrections"
)
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Add estimation_report_json column to v3_plans."""
    op.add_column(
        "v3_plans",
        sa.Column("estimation_report_json", sa.Text(), nullable=True),
    )


def downgrade() -> None:
    """Remove estimation_report_json column from v3_plans."""
    op.drop_column("v3_plans", "estimation_report_json")
