Version: 0.9.59.dev.260430
后端: 1. 主动调度预览确认主链路落地——新增主动调度数据模型、DAO 与事件契约;接入 dry-run pipeline 与任务触发的 job upsert/cancel;新增 preview 查询与 confirm API,支持 apply_id 幂等确认并同步写入 task_pool 日程 2. 同步更新主动调度实施文档的阶段状态与验收记录 前端: 3. AssistantPanel 脚本层继续解耦——私有类型迁移到独立类型文件,并抽离会话、工具轨迹、思考摘要、任务表单等纯函数辅助逻辑;保持助手面板模板与样式不变,降低表现层回归风险
This commit is contained in:
@@ -21,6 +21,10 @@ func autoMigrateModels(db *gorm.DB) error {
|
||||
&model.TaskClassItem{},
|
||||
&model.ScheduleEvent{},
|
||||
&model.Schedule{},
|
||||
&model.ActiveScheduleJob{},
|
||||
&model.ActiveScheduleTrigger{},
|
||||
&model.ActiveSchedulePreview{},
|
||||
&model.NotificationRecord{},
|
||||
&model.AgentOutboxMessage{},
|
||||
&model.AgentScheduleState{},
|
||||
&model.AgentStateSnapshotRecord{},
|
||||
@@ -35,6 +39,30 @@ func autoMigrateModels(db *gorm.DB) error {
|
||||
return fmt.Errorf("auto migrate failed for %T: %w", m, err)
|
||||
}
|
||||
}
|
||||
if err := backfillAutoMigrateData(db); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// backfillAutoMigrateData 补齐 AutoMigrate 无法表达的条件回填。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只处理新增列上线后的兼容数据修复,不替代业务迁移系统;
|
||||
// 2. 当前仅回填历史动态任务日程来源,确保旧的 type=task 记录按 task_item 解释;
|
||||
// 3. 失败时直接返回错误,避免服务在 schema 半迁移状态下继续启动。
|
||||
func backfillAutoMigrateData(db *gorm.DB) error {
|
||||
// 1. AutoMigrate 只能新增列和默认值,不能表达"仅 type=task 时回填"。
|
||||
// 2. 这里把历史任务日程显式标记为 task_item,避免后续主动调度读取 rel_id 时误判来源。
|
||||
// 3. 新增 task_pool 正式落库仍必须由 apply 链路显式写 task_source_type=task_pool。
|
||||
result := db.Exec(
|
||||
"UPDATE schedule_events SET task_source_type = ? WHERE type = ? AND (task_source_type IS NULL OR task_source_type = '')",
|
||||
"task_item",
|
||||
"task",
|
||||
)
|
||||
if result.Error != nil {
|
||||
return fmt.Errorf("backfill schedule_events.task_source_type failed: %w", result.Error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user