upgrade for latest version of go-toolkit/app
This commit is contained in:
8
db.go
8
db.go
@@ -64,7 +64,7 @@ func ModuleDB(cfg DBConfig, forceDebugLog bool) *app.Module {
|
|||||||
|
|
||||||
// setupDB connects to the MySQL DB and initializes the goose migration provider.
|
// setupDB connects to the MySQL DB and initializes the goose migration provider.
|
||||||
// If auto migrations are enabled in configuration, latest migrations are applied.
|
// If auto migrations are enabled in configuration, latest migrations are applied.
|
||||||
func setupDB() error {
|
func setupDB(_ *app.Module) error {
|
||||||
if sqlDB != nil && sqlDB.Ping() == nil {
|
if sqlDB != nil && sqlDB.Ping() == nil {
|
||||||
dbModule.Logger().Warn("Database connection already established")
|
dbModule.Logger().Warn("Database connection already established")
|
||||||
return nil
|
return nil
|
||||||
@@ -105,15 +105,17 @@ func setupDB() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// teardownDB closes the database connection.
|
// teardownDB closes the database connection.
|
||||||
func teardownDB() {
|
func teardownDB(_ *app.Module) error {
|
||||||
if sqlDB == nil {
|
if sqlDB == nil {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sqlDB.Close(); err != nil {
|
if err := sqlDB.Close(); err != nil {
|
||||||
dbModule.Logger().Error("Couldn't close database", "err", err)
|
dbModule.Logger().Error("Couldn't close database", "err", err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
dbModule.Logger().Info("Closed database connection")
|
dbModule.Logger().Info("Closed database connection")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queryable interface is an SQL driver object that can execute SQL statements
|
// Queryable interface is an SQL driver object that can execute SQL statements
|
||||||
|
|||||||
Reference in New Issue
Block a user