59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
|
|
"""add participants field to conversations table
|
||
|
|
|
||
|
|
为会话表添加 participants JSON 字段,支持邀请功能(P0-09~P0-11)。
|
||
|
|
与 collaborating_agent_ids(摇人 = 坐席间协作)独立,
|
||
|
|
participants 存储被邀请的员工/部门列表。
|
||
|
|
|
||
|
|
新增字段:
|
||
|
|
- participants: JSON, 非空, 默认空列表, 被邀请参与会话的人员列表
|
||
|
|
|
||
|
|
数据格式:
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"id": "employee_user_id",
|
||
|
|
"name": "员工姓名",
|
||
|
|
"department": "部门名称",
|
||
|
|
"type": "employee", # employee 或 department
|
||
|
|
"joined": false, # 是否已加入会话
|
||
|
|
"joined_at": null, # 加入时间
|
||
|
|
"invited_by": "agent_id" # 邀请人坐席ID
|
||
|
|
}
|
||
|
|
]
|
||
|
|
|
||
|
|
Revision ID: 004_participants
|
||
|
|
Revises: 003_suggestion_action
|
||
|
|
Create Date: 2026-07-14 14:00:00.000000
|
||
|
|
"""
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
# revision identifiers, used by Alembic.
|
||
|
|
revision = '004_participants'
|
||
|
|
down_revision = '003_suggestion_action'
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
"""添加 participants 字段到 conversations 表。"""
|
||
|
|
# 被邀请参与会话的人员列表(JSON 数组)
|
||
|
|
# 与 collaborating_agent_ids 区别:
|
||
|
|
# collaborating_agent_ids = 坐席→坐席协作(摇人)
|
||
|
|
# participants = 坐席→员工/部门(邀请)
|
||
|
|
op.add_column(
|
||
|
|
'conversations',
|
||
|
|
sa.Column(
|
||
|
|
'participants',
|
||
|
|
sa.JSON,
|
||
|
|
nullable=False,
|
||
|
|
server_default='[]', # 默认空数组
|
||
|
|
comment='被邀请参与会话的人员列表(邀请功能)',
|
||
|
|
)
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
"""移除 participants 字段。"""
|
||
|
|
op.drop_column('conversations', 'participants')
|