2023-09-18 17:22:21 +08:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
|
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var AddDefaultNetwork = &gormigrate.Migration{
|
2023-09-28 15:40:17 +08:00
|
|
|
ID: "20230928-add-default-network",
|
2023-09-18 17:22:21 +08:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
2023-10-11 14:32:28 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "DefaultNetwork", Value: "all"}).Error; err != nil {
|
2023-09-18 17:22:21 +08:00
|
|
|
return err
|
|
|
|
}
|
2023-09-28 15:40:17 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "LastCleanTime", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "LastCleanSize", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "LastCleanData", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-09-18 17:22:21 +08:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-09-25 17:50:14 +08:00
|
|
|
|
|
|
|
var UpdateRuntime = &gormigrate.Migration{
|
2023-09-28 15:28:21 +08:00
|
|
|
ID: "20230927-update-runtime",
|
2023-09-25 17:50:14 +08:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.AutoMigrate(&model.Runtime{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-10-08 14:54:14 +08:00
|
|
|
|
|
|
|
var UpdateTag = &gormigrate.Migration{
|
|
|
|
ID: "20231008-update-tag",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.AutoMigrate(&model.Tag{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|