package initialize import ( "os" "srm/model/purchase" "go.uber.org/zap" "gorm.io/gorm" "srm/global" "srm/model/test" ) func Gorm() *gorm.DB { switch global.GVA_CONFIG.System.DbType { case "mysql": return GormMysql() case "pgsql": return GormPgSql() case "oracle": return GormOracle() case "mssql": return GormMssql() case "sqlite": return GormSqlite() default: return GormMysql() } } func RegisterTables() { db := global.GVA_DB err := db.AutoMigrate( test.Industry{}, test.SupplierType{}, test.Supplier{}, test.Contract{}, test.SupplierMaterial{}, purchase.Purchase{}, purchase.PurchaseProducts{}, ) if err != nil { global.GVA_LOG.Error("register table failed", zap.Error(err)) os.Exit(0) } global.GVA_LOG.Info("register table success") }