"""add features_json and analyze_status to benchmark_notes

Revision ID: 009
Revises: 008
Create Date: 2026-06-13

第2环标杆分析字段：
- features_json: 存储8特征结构化分析结果（TEXT JSON）
- analyze_status: AI分析状态机 pending/analyzing/done/failed
"""
from alembic import op
import sqlalchemy as sa

revision = "009"
down_revision = "008"
branch_labels = None
depends_on = None


def upgrade():
    op.add_column(
        "benchmark_notes",
        sa.Column(
            "features_json",
            sa.Text,
            nullable=True,
            comment="爆款8特征分析结果（JSON），第2环AI解析后写入",
        ),
    )
    op.add_column(
        "benchmark_notes",
        sa.Column(
            "analyze_status",
            sa.String(20),
            nullable=False,
            server_default="pending",
            comment="AI分析状态: pending/analyzing/done/failed",
        ),
    )


def downgrade():
    op.drop_column("benchmark_notes", "analyze_status")
    op.drop_column("benchmark_notes", "features_json")
