mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 23:17:21 +08:00
fix: Fix the problem of initializing planned task groups (#9870)
This commit is contained in:
parent
da7968d364
commit
305eff048c
3 changed files with 15 additions and 1 deletions
|
@ -11,7 +11,7 @@ type Cronjob struct {
|
|||
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Type string `gorm:"not null" json:"type"`
|
||||
GroupID uint `gorm:"not null;default:0" json:"groupID"`
|
||||
GroupID uint `json:"groupID"`
|
||||
SpecCustom bool `json:"specCustom"`
|
||||
Spec string `gorm:"not null" json:"spec"`
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ func InitAgentDB() {
|
|||
migrations.AddMethodToAlertLog,
|
||||
migrations.AddMethodToAlertTask,
|
||||
migrations.UpdateMcpServer,
|
||||
migrations.InitCronjobGroup,
|
||||
})
|
||||
if err := m.Migrate(); err != nil {
|
||||
global.LOG.Error(err)
|
||||
|
|
|
@ -433,3 +433,16 @@ var UpdateMcpServer = &gormigrate.Migration{
|
|||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var InitCronjobGroup = &gormigrate.Migration{
|
||||
ID: "20250805-init-cronjob-group",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
if err := tx.AutoMigrate(&model.Cronjob{}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Model(&model.Cronjob{}).Where("1=1").Updates(map[string]interface{}{"group_id": 0}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue