"""Add characterization JSONB column to chapter_reviews (灵感③ advisory 人物塑造审).

单列 JSONB nullable（advisory 留痕，独立于恒 None 的 health_score）；nullable 免 backfill
（旧留痕行留 NULL，collect/前端优雅降级）。仅建议、不进 conflicts、不碰验收 gate（灵感 D2）。

Revision ID: f6a7b8c9d0e1
Revises: e5f6a7b8c9d0
Create Date: 2026-07-06 00:00:00.000000
"""

from __future__ import annotations

from collections.abc import Sequence

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

revision: str = "f6a7b8c9d0e1"
down_revision: str | None = "e5f6a7b8c9d0"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.add_column(
        "chapter_reviews",
        sa.Column("characterization", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("chapter_reviews", "characterization")
