feat: 添加 migrateProxyRouteEnableHTTPSColumn 方法以重命名 ProxyRoute 中的 enable_http_s 列为 enable_https,并在 InitDB 中调用该方法

This commit is contained in:
ryan
2026-03-11 11:14:40 +08:00
parent efcc6b5337
commit 16ea572183
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -10,6 +10,16 @@ import (
var DB *gorm.DB
func migrateProxyRouteEnableHTTPSColumn(db *gorm.DB) error {
if !db.Migrator().HasTable(&ProxyRoute{}) {
return nil
}
if db.Migrator().HasColumn(&ProxyRoute{}, "enable_https") || !db.Migrator().HasColumn(&ProxyRoute{}, "enable_http_s") {
return nil
}
return db.Migrator().RenameColumn(&ProxyRoute{}, "enable_http_s", "enable_https")
}
func createRootAccountIfNeed() error {
var user User
//if user.Status != common.UserStatusEnabled {
@@ -52,6 +62,9 @@ func InitDB() (err error) {
}
if err == nil {
DB = db
if err = migrateProxyRouteEnableHTTPSColumn(db); err != nil {
return err
}
err := db.AutoMigrate(&File{})
if err != nil {
return err