"""add suggestion_action field to messages table

为消息表添加 suggestion_action 字段，用于追踪坐席对 AI 建议的操作行为。
取值范围：accepted（采纳）/ edited（编辑后采纳）/ ignored（忽略）

新增字段：
- suggestion_action: VARCHAR(20), nullable, 坐席对AI建议的操作行为

Revision ID: 003_suggestion_action
Revises: 002_media_fields
Create Date: 2026-07-14 10:00:00.000000
"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '003_suggestion_action'
down_revision = '002_media_fields'
branch_labels = None
depends_on = None


def upgrade() -> None:
    """添加 suggestion_action 字段到 messages 表。"""
    # 坐席对 AI 建议的操作行为（accepted/edited/ignored）
    op.add_column(
        'messages',
        sa.Column(
            'suggestion_action',
            sa.String(20),
            nullable=True,
            comment='AI建议操作行为: accepted/edited/ignored',
        )
    )


def downgrade() -> None:
    """移除 suggestion_action 字段。"""
    op.drop_column('messages', 'suggestion_action')
