mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-11 00:23:42 +08:00
chore: drop idx_channels_key on start
This commit is contained in:
@@ -2,5 +2,6 @@ package common
|
|||||||
|
|
||||||
var UsingSQLite = false
|
var UsingSQLite = false
|
||||||
var UsingPostgreSQL = false
|
var UsingPostgreSQL = false
|
||||||
|
var UsingMySQL = false
|
||||||
|
|
||||||
var SQLitePath = "one-api.db?_busy_timeout=5000"
|
var SQLitePath = "one-api.db?_busy_timeout=5000"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func chooseDB() (*gorm.DB, error) {
|
|||||||
dsn += "?parseTime=true"
|
dsn += "?parseTime=true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
common.UsingMySQL = true
|
||||||
return gorm.Open(mysql.Open(dsn), &gorm.Config{
|
return gorm.Open(mysql.Open(dsn), &gorm.Config{
|
||||||
PrepareStmt: true, // precompile SQL
|
PrepareStmt: true, // precompile SQL
|
||||||
})
|
})
|
||||||
@@ -92,6 +93,9 @@ func InitDB() (err error) {
|
|||||||
if !common.IsMasterNode {
|
if !common.IsMasterNode {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if common.UsingMySQL {
|
||||||
|
_, _ = sqlDB.Exec("DROP INDEX idx_channels_key ON channels;") // TODO: delete this line when most users have upgraded
|
||||||
|
}
|
||||||
common.SysLog("database migration started")
|
common.SysLog("database migration started")
|
||||||
err = db.AutoMigrate(&Channel{})
|
err = db.AutoMigrate(&Channel{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user