mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 23:56:37 +08:00
feat: 添加 migrateProxyRouteEnableHTTPSColumn 方法以重命名 ProxyRoute 中的 enable_http_s 列为 enable_https,并在 InitDB 中调用该方法
This commit is contained in:
@@ -10,6 +10,16 @@ import (
|
|||||||
|
|
||||||
var DB *gorm.DB
|
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 {
|
func createRootAccountIfNeed() error {
|
||||||
var user User
|
var user User
|
||||||
//if user.Status != common.UserStatusEnabled {
|
//if user.Status != common.UserStatusEnabled {
|
||||||
@@ -52,6 +62,9 @@ func InitDB() (err error) {
|
|||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
DB = db
|
DB = db
|
||||||
|
if err = migrateProxyRouteEnableHTTPSColumn(db); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
err := db.AutoMigrate(&File{})
|
err := db.AutoMigrate(&File{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type ProxyRoute struct {
|
|||||||
Domain string `json:"domain" gorm:"uniqueIndex;size:255;not null"`
|
Domain string `json:"domain" gorm:"uniqueIndex;size:255;not null"`
|
||||||
OriginURL string `json:"origin_url" gorm:"size:2048;not null"`
|
OriginURL string `json:"origin_url" gorm:"size:2048;not null"`
|
||||||
Enabled bool `json:"enabled" gorm:"not null;default:true"`
|
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"`
|
CertID *uint `json:"cert_id"`
|
||||||
RedirectHTTP bool `json:"redirect_http" gorm:"not null;default:false"`
|
RedirectHTTP bool `json:"redirect_http" gorm:"not null;default:false"`
|
||||||
CustomHeaders string `json:"custom_headers" gorm:"type:text;not null;default:'[]'"`
|
CustomHeaders string `json:"custom_headers" gorm:"type:text;not null;default:'[]'"`
|
||||||
|
|||||||
Reference in New Issue
Block a user