-- 添加播课异步生成状态管理字段
-- 日期: 2025-10-14

USE kaopeilian;

-- 添加播课生成状态字段
ALTER TABLE courses 
ADD COLUMN broadcast_status VARCHAR(20) NULL COMMENT '播课生成状态: pending/generating/completed/failed';

-- 添加Coze工作流任务ID字段
ALTER TABLE courses 
ADD COLUMN broadcast_task_id VARCHAR(100) NULL COMMENT 'Coze工作流任务ID';

-- 添加错误信息字段
ALTER TABLE courses 
ADD COLUMN broadcast_error_message TEXT NULL COMMENT '生成失败错误信息';

-- 验证字段添加
SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_COMMENT 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'kaopeilian' 
  AND TABLE_NAME = 'courses' 
  AND COLUMN_NAME IN ('broadcast_status', 'broadcast_task_id', 'broadcast_error_message');

