mirror of
				https://github.com/linux-do/new-api.git
				synced 2025-11-04 21:33:41 +08:00 
			
		
		
		
	chore: drop idx_channels_key on start
This commit is contained in:
		@@ -2,5 +2,6 @@ package common
 | 
			
		||||
 | 
			
		||||
var UsingSQLite = false
 | 
			
		||||
var UsingPostgreSQL = false
 | 
			
		||||
var UsingMySQL = false
 | 
			
		||||
 | 
			
		||||
var SQLitePath = "one-api.db?_busy_timeout=5000"
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,7 @@ func chooseDB() (*gorm.DB, error) {
 | 
			
		||||
				dsn += "?parseTime=true"
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		common.UsingMySQL = true
 | 
			
		||||
		return gorm.Open(mysql.Open(dsn), &gorm.Config{
 | 
			
		||||
			PrepareStmt: true, // precompile SQL
 | 
			
		||||
		})
 | 
			
		||||
@@ -92,6 +93,9 @@ func InitDB() (err error) {
 | 
			
		||||
		if !common.IsMasterNode {
 | 
			
		||||
			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")
 | 
			
		||||
		err = db.AutoMigrate(&Channel{})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user