fix: 修改数据库 migration (#2105)

pull/2108/head
ssongliu 2023-08-29 14:36:16 +08:00 committed by GitHub
parent 49e3d45912
commit 9f38a78512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -39,6 +39,7 @@ func Init() {
migrations.UpdateRedisParam,
migrations.UpdateCronjobWithDb,
migrations.AddTableFirewall,
migrations.AddMariaDB,
migrations.UpdateDatabase,
})
if err := m.Migrate(); err != nil {

View File

@ -584,8 +584,8 @@ var AddTableFirewall = &gormigrate.Migration{
},
}
var UpdateDatabase = &gormigrate.Migration{
ID: "20230828-update-database",
var AddMariaDB = &gormigrate.Migration{
ID: "20230828-add-mariadb",
Migrate: func(tx *gorm.DB) error {
var (
app model.App
@ -624,7 +624,13 @@ var UpdateDatabase = &gormigrate.Migration{
}).Error; err != nil {
return err
}
return nil
},
}
var UpdateDatabase = &gormigrate.Migration{
ID: "20230829-update-database",
Migrate: func(tx *gorm.DB) error {
if err := global.DB.Model(&model.DatabaseMysql{}).Where("`from` != ?", "local").Updates(map[string]interface{}{
"from": "remote",
}).Error; err != nil {