You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
613 B

package initialize
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"gorm.io/gorm"
)
const sys = "system"
func DBList() {
dbMap := make(map[string]*gorm.DB)
for _, info := range global.GVA_CONFIG.DBList {
if info.Disable {
continue
}
switch info.Type {
case "mysql":
dbMap[info.Dbname] = GormMysqlByConfig(info)
case "pgsql":
dbMap[info.Dbname] = GormPgSqlByConfig(info)
default:
continue
}
}
// 做特殊判断,是否有迁移
// 适配低版本迁移多数据库版本
if sysDB, ok := dbMap[sys]; ok {
global.GVA_DB = sysDB
}
global.GVA_DBList = dbMap
}