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.

29 lines
511 B

3 years ago
  1. package initialize
  2. import (
  3. "autocode/global"
  4. "gorm.io/gorm"
  5. )
  6. const sys = "system"
  7. func DBList() {
  8. dbMap := make(map[string]*gorm.DB)
  9. for _, info := range global.GVA_CONFIG.DBList {
  10. if info.Disable {
  11. continue
  12. }
  13. switch info.Type {
  14. case "pgsql":
  15. dbMap[info.Dbname] = GormPgSqlByConfig(info)
  16. default:
  17. continue
  18. }
  19. }
  20. // 做特殊判断,是否有迁移
  21. // 适配低版本迁移多数据库版本
  22. if sysDB, ok := dbMap[sys]; ok {
  23. global.GVA_DB = sysDB
  24. }
  25. global.GVA_DBList = dbMap
  26. }