"""为 predictions 表增加 agent_weights 列 Revision ID: 0014_predictions_agent_weights Revises: 0013_predictions_unique_constraint_mode_run_type Create Date: 2026-09-20 背景: multi-agent 终裁的 agent_weights 原本只在 raw_response JSON 中, 无独立列,评估不便。本迁移增加 agent_weights JSONB 列,可空,旧行保持 NULL。 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = '0014_predictions_agent_weights' down_revision: Union[str, None] = '0013_predictions_unique_constraint_mode_run_type' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # 新增 agent_weights 列(JSONB, 可空, 旧行保持 NULL) op.add_column( "predictions", sa.Column( "agent_weights", sa.dialects.postgresql.JSONB(), nullable=True, comment="multi-agent 终裁各专家权重, 格式: {expert_name: weight}", ), ) def downgrade() -> None: # 删除 agent_weights 列 op.drop_column("predictions", "agent_weights")