diff --git a/model/main.go b/model/main.go index a29dd36..e9a3bdd 100644 --- a/model/main.go +++ b/model/main.go @@ -272,6 +272,8 @@ func migrateDB() error { if err := migrateTokenModelLimitsToText(); err != nil { return err } + // Clear legacy external docs_link so the in-app /docs page is used by default + migrateDocsLinkToDefault() // GORM AutoMigrate + Postgres: MigrateColumnUnique drops NamingStrategy.UniqueName(table, col) // when the column is UNIQUE in information_schema but the model uses uniqueIndex (field.Unique=false). // If the live constraint was created with another name (e.g. Postgres default), DROP uni_* fails (SQLSTATE 42704). @@ -583,6 +585,28 @@ func migrateTokenModelLimitsToText() error { return nil } +// migrateDocsLinkToDefault clears any external docs_link saved in DB so the in-app /docs page is used. +// Admins can still re-configure an external link via Settings UI if desired. +func migrateDocsLinkToDefault() { + if DB == nil { + return + } + key := "general_setting.docs_link" + var opt Option + if err := DB.Where("`key` = ?", key).First(&opt).Error; err != nil { + // No existing record or table doesn't exist — nothing to migrate + return + } + if opt.Value == "" { + return + } + if err := DB.Model(&Option{}).Where("`key` = ?", key).Update("value", "").Error; err != nil { + common.SysLog(fmt.Sprintf("migrateDocsLinkToDefault: failed to clear %s: %v", key, err)) + return + } + common.SysLog("migrateDocsLinkToDefault: cleared legacy docs_link, now using in-app /docs page") +} + // migrateSubscriptionPlanPriceAmount migrates price_amount column from float/double to decimal(10,6) // This is safe to run multiple times - it checks the column type first func migrateSubscriptionPlanPriceAmount() { diff --git a/setting/operation_setting/general_setting.go b/setting/operation_setting/general_setting.go index 4dcca32..d88683a 100644 --- a/setting/operation_setting/general_setting.go +++ b/setting/operation_setting/general_setting.go @@ -51,7 +51,7 @@ type GeneralSetting struct { // 默认配置 var generalSetting = GeneralSetting{ - DocsLink: "https://docs.newapi.pro", + DocsLink: "", DefaultSiteLanguage: "zh-CN", PingIntervalEnabled: false, PingIntervalSeconds: 60,