设置迁移开关

This commit is contained in:
suziheng 2024-12-02 10:32:39 +08:00
parent 4ae311e964
commit a9f42abb59

View File

@ -108,6 +108,7 @@ func InitDB(envName string) (db *gorm.DB, err error) {
if common.UsingMySQL {
_, _ = sqlDB.Exec("DROP INDEX idx_channels_key ON channels;") // TODO: delete this line when most users have upgraded
}
if env.Bool("StartSqlMigration", false) {
logger.SysLog("database migration started")
err = db.AutoMigrate(&Channel{})
if err != nil {
@ -138,6 +139,7 @@ func InitDB(envName string) (db *gorm.DB, err error) {
return nil, err
}
logger.SysLog("database migrated")
}
return db, err
} else {
logger.FatalLog(err)