From 12909f9c2142ed0c19bd660fb6879c4c659e2893 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 25 Mar 2024 10:48:21 +0100 Subject: [PATCH] Database: Drop `registerDriverOnce` variable --- pkg/config/database.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/config/database.go b/pkg/config/database.go index a71378813..1107d59fc 100644 --- a/pkg/config/database.go +++ b/pkg/config/database.go @@ -17,12 +17,9 @@ import ( "net/url" "strconv" "strings" - "sync" "time" ) -var registerDriverOnce sync.Once - // Database defines database client configuration. type Database struct { Type string `yaml:"type" default:"mysql"` @@ -38,10 +35,6 @@ type Database struct { // Open prepares the DSN string and driver configuration, // calls sqlx.Open, but returns *icingadb.DB. func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) { - registerDriverOnce.Do(func() { - icingadb.Register(logger) - }) - var db *sqlx.DB switch d.Type { case "mysql": @@ -78,6 +71,8 @@ func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) { } } + icingadb.Register(logger) + c, err := mysql.NewConnector(config) if err != nil { return nil, errors.Wrap(err, "can't open mysql database")