diff --git a/Makefile b/Makefile index 9ffc57bc..bc65ec84 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,8 @@ endif test: ## run tests with race detactor go test -race ./... -clean: ## remove the output binary from go build, as well as go install and entire module download cache for safety - go clean -modcache - go clean -i +clean: ## remove the output binary from go build, as well as go install and build cache + go clean -i -r -cache .PHONY: build build-race build-slim lint test clean diff --git a/framework/bean/bean.go b/framework/bean/bean.go index f0293f25..21f924c1 100644 --- a/framework/bean/bean.go +++ b/framework/bean/bean.go @@ -90,7 +90,7 @@ type Config struct { On bool Secret string } - SQL dbdrivers.SQLConfig + MySQL dbdrivers.SQLConfig Mongo dbdrivers.MongoConfig Redis dbdrivers.RedisConfig Badger dbdrivers.BadgerConfig @@ -332,12 +332,12 @@ func (b *Bean) InitDB() { var tenantRedisDBNames map[uint64]int if b.Config.Database.Tenant.On { - masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.SQL) - tenantMySQLDBs, tenantMySQLDBNames = dbdrivers.InitMysqlTenantConns(b.Config.Database.SQL, masterMySQLDB, b.Config.Database.Tenant.Secret) + masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.MySQL) + tenantMySQLDBs, tenantMySQLDBNames = dbdrivers.InitMysqlTenantConns(b.Config.Database.MySQL, masterMySQLDB, b.Config.Database.Tenant.Secret) tenantMongoDBs, tenantMongoDBNames = dbdrivers.InitMongoTenantConns(b.Config.Database.Mongo, masterMySQLDB, b.Config.Database.Tenant.Secret) tenantRedisDBs, tenantRedisDBNames = dbdrivers.InitRedisTenantConns(b.Config.Database.Redis, masterMySQLDB, b.Config.Database.Tenant.Secret) } else { - masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.SQL) + masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.MySQL) masterMongoDB, masterMongoDBName = dbdrivers.InitMongoMasterConn(b.Config.Database.Mongo) masterRedisDB, masterRedisDBName = dbdrivers.InitRedisMasterConn(b.Config.Database.Redis) } diff --git a/framework/dbdrivers/mysql.go b/framework/dbdrivers/mysql.go index 39527fc2..48e8c5b9 100644 --- a/framework/dbdrivers/mysql.go +++ b/framework/dbdrivers/mysql.go @@ -53,7 +53,7 @@ func InitMysqlMasterConn(config SQLConfig) (*gorm.DB, string) { masterCfg := config.Master - if masterCfg != nil { + if masterCfg != nil && masterCfg.Database != "" { return connectMysqlDB(masterCfg.Username, masterCfg.Password, masterCfg.Host, masterCfg.Port, masterCfg.Database, config.MaxIdleConnections, config.MaxOpenConnections, config.MaxConnectionLifeTime, config.Debug) } diff --git a/internal/project/Makefile b/internal/project/Makefile index de168051..a15da318 100644 --- a/internal/project/Makefile +++ b/internal/project/Makefile @@ -23,8 +23,7 @@ endif test: ## run tests with race detactor go test -race ./... -clean: ## remove the output binary from go build, as well as go install and entire module download cache for safety - go clean -modcache - go clean -i +clean: ## remove the output binary from go build, as well as go install and build cache + go clean -i -r -cache .PHONY: build build-race build-slim lint test clean diff --git a/internal/project/env.json b/internal/project/env.json index 38589ad0..c5ed3349 100644 --- a/internal/project/env.json +++ b/internal/project/env.json @@ -32,9 +32,9 @@ }, "mysql": { "master":{ - "database": "naviee_master", - "username": "master", - "password": "secret", + "database": "", + "username": "", + "password": "", "host": "127.0.0.1", "port": "3306" }, diff --git a/internal/project/go.mod.tmp b/internal/project/go.mod.tmp index 2ce1c682..2df8f951 100644 --- a/internal/project/go.mod.tmp +++ b/internal/project/go.mod.tmp @@ -7,7 +7,7 @@ require ( github.com/go-playground/validator/v10 v10.9.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/labstack/echo/v4 v4.6.3 - github.com/retail-ai-inc/bean v1.1.0 + github.com/retail-ai-inc/bean v1.1.1 github.com/spf13/cobra v1.3.0 github.com/spf13/viper v1.10.0 )