mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-11 16:06:02 +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"`
|
Name string `gorm:"not null" json:"name"`
|
||||||
Type string `gorm:"not null" json:"type"`
|
Type string `gorm:"not null" json:"type"`
|
||||||
GroupID uint `gorm:"not null;default:0" json:"groupID"`
|
GroupID uint `json:"groupID"`
|
||||||
SpecCustom bool `json:"specCustom"`
|
SpecCustom bool `json:"specCustom"`
|
||||||
Spec string `gorm:"not null" json:"spec"`
|
Spec string `gorm:"not null" json:"spec"`
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ func InitAgentDB() {
|
||||||
migrations.AddMethodToAlertLog,
|
migrations.AddMethodToAlertLog,
|
||||||
migrations.AddMethodToAlertTask,
|
migrations.AddMethodToAlertTask,
|
||||||
migrations.UpdateMcpServer,
|
migrations.UpdateMcpServer,
|
||||||
|
migrations.InitCronjobGroup,
|
||||||
})
|
})
|
||||||
if err := m.Migrate(); err != nil {
|
if err := m.Migrate(); err != nil {
|
||||||
global.LOG.Error(err)
|
global.LOG.Error(err)
|
||||||
|
|
|
@ -433,3 +433,16 @@ var UpdateMcpServer = &gormigrate.Migration{
|
||||||
return nil
|
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