From 16ea572183c12e88df2d3e81bd877e9a2926cb65 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 11 Mar 2026 11:14:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20migrateProxyRouteE?= =?UTF-8?q?nableHTTPSColumn=20=E6=96=B9=E6=B3=95=E4=BB=A5=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=20ProxyRoute=20=E4=B8=AD=E7=9A=84=20enable?= =?UTF-8?q?=5Fhttp=5Fs=20=E5=88=97=E4=B8=BA=20enable=5Fhttps=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=9C=A8=20InitDB=20=E4=B8=AD=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E8=AF=A5=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atsf_server/model/main.go | 13 +++++++++++++ atsf_server/model/proxy_route.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/atsf_server/model/main.go b/atsf_server/model/main.go index 45146a5d..c9d65fe0 100644 --- a/atsf_server/model/main.go +++ b/atsf_server/model/main.go @@ -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 diff --git a/atsf_server/model/proxy_route.go b/atsf_server/model/proxy_route.go index 2fab4b6f..d0863fba 100644 --- a/atsf_server/model/proxy_route.go +++ b/atsf_server/model/proxy_route.go @@ -7,7 +7,7 @@ type ProxyRoute struct { Domain string `json:"domain" gorm:"uniqueIndex;size:255;not null"` OriginURL string `json:"origin_url" gorm:"size:2048;not null"` Enabled bool `json:"enabled" gorm:"not null;default:true"` - EnableHTTPS bool `json:"enable_https" gorm:"not null;default:false"` + EnableHTTPS bool `json:"enable_https" gorm:"column:enable_https;not null;default:false"` CertID *uint `json:"cert_id"` RedirectHTTP bool `json:"redirect_http" gorm:"not null;default:false"` CustomHeaders string `json:"custom_headers" gorm:"type:text;not null;default:'[]'"`