diff --git a/db.go b/db.go index 2f4e193..c1ea52f 100644 --- a/db.go +++ b/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. // 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 { dbModule.Logger().Warn("Database connection already established") return nil @@ -105,15 +105,17 @@ func setupDB() error { } // teardownDB closes the database connection. -func teardownDB() { +func teardownDB(_ *app.Module) error { if sqlDB == nil { - return + return nil } if err := sqlDB.Close(); err != nil { dbModule.Logger().Error("Couldn't close database", "err", err) + return err } dbModule.Logger().Info("Closed database connection") + return nil } // Queryable interface is an SQL driver object that can execute SQL statements