优化索引
This commit is contained in:
@@ -53,8 +53,8 @@ type Plan struct {
|
||||
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
ExecutionType PlanExecutionType `gorm:"not null" json:"execution_type"`
|
||||
Status PlanStatus `gorm:"default:0" json:"status"` // 计划是否被启动
|
||||
ExecutionType PlanExecutionType `gorm:"not null;index" json:"execution_type"`
|
||||
Status PlanStatus `gorm:"default:0;index" json:"status"` // 计划是否被启动
|
||||
ExecuteNum uint `gorm:"default:0" json:"execute_num"` // 计划预期执行次数
|
||||
ExecuteCount uint `gorm:"default:0" json:"execute_count"` // 执行计数器
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ type PendingTask struct {
|
||||
// GORM 会根据 TaskID 字段自动填充此关联
|
||||
Task *Task `gorm:"foreignKey:TaskID"`
|
||||
|
||||
ExecuteAt time.Time `gorm:"index"` // 任务执行时间
|
||||
TaskExecutionLogID uint `gorm:"unique;not null"` // 对应的执行历史记录ID
|
||||
ExecuteAt time.Time `gorm:"index"` // 任务执行时间
|
||||
TaskExecutionLogID uint `gorm:"unique;not null;index"` // 对应的执行历史记录ID
|
||||
|
||||
// 通过 TaskExecutionLogID 关联到唯一的 TaskExecutionLog 记录
|
||||
// ON DELETE CASCADE 确保如果日志被删除,这个待办任务也会被自动清理
|
||||
|
||||
Reference in New Issue
Block a user