From 5bac51a67c09648258dbdb6e8f127d1dc3e34abc Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:19:42 +0800 Subject: [PATCH 01/16] Access error directly via variable --- scripts/create_db.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 4cb0612..fc9fa9f 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -96,9 +96,9 @@ func dropDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { func getConnectedDBName(db *gorm.DB) (string, error) { var dbName string - result := db.Raw("SELECT current_database();").Scan(&dbName) - if result.Error != nil { - return "", result.Error + err := db.Raw("SELECT current_database();").Scan(&dbName).Error + if err != nil { + return "", err } return dbName, nil } From 1aed3cb2c5a2e8268b557799dec98eea9ad04475 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:20:32 +0800 Subject: [PATCH 02/16] Remove unnecesary 'if' clause The default value of a string variable is already an empty string, and there was no additional error handling done. --- scripts/create_db.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index fc9fa9f..7e81912 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -97,8 +97,5 @@ func dropDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { func getConnectedDBName(db *gorm.DB) (string, error) { var dbName string err := db.Raw("SELECT current_database();").Scan(&dbName).Error - if err != nil { - return "", err - } - return dbName, nil + return dbName, err } From 902a112e2978359d32d6c0b624d63ace018fbe7b Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:22:51 +0800 Subject: [PATCH 03/16] Move printing logic to main script Allows for better abstraction and improves reusability. --- scripts/create_db.go | 6 ------ scripts/db.go | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 7e81912..95f4d0f 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -28,12 +28,6 @@ func connectDBHelper(dsn string) (*gorm.DB, error) { return nil, err } - dbName, err := getConnectedDBName(db) - if err != nil { - panic(err) - } - fmt.Println(blueSandwich, "Connected to database", dbName+".") - return db, nil } diff --git a/scripts/db.go b/scripts/db.go index 0a85f72..fb51a6d 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -58,6 +58,12 @@ func main() { } defer closeDBConnection(d) + dbName, err := getConnectedDBName(d) + if err != nil { + panic(err) + } + fmt.Println(blueSandwich, "Connected to database", dbName+".") + switch flag.Arg(0) { case "drop": err := dropDB(d, conf.Database) From e4298dbb1e910a99c9ce21d07451a72135fadf68 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:25:37 +0800 Subject: [PATCH 04/16] Refactor to use common DB "connect" helper Reduces code duplication. --- scripts/create_db.go | 23 ----------------------- scripts/db.go | 12 ++++++------ 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 95f4d0f..503b3f9 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -5,32 +5,9 @@ import ( "fmt" "github.com/source-academy/stories-backend/internal/config" - "gorm.io/driver/postgres" "gorm.io/gorm" ) -func connectAnonDB(conf config.DatabaseConfig) (*gorm.DB, error) { - conf.DatabaseName = "" - dsn := conf.ToDataSourceName() - return connectDBHelper(dsn) -} - -func connectDB(conf config.DatabaseConfig) (*gorm.DB, error) { - dsn := conf.ToDataSourceName() - return connectDBHelper(dsn) -} - -func connectDBHelper(dsn string) (*gorm.DB, error) { - driver := postgres.Open(dsn) - - db, err := gorm.Open(driver, &gorm.Config{}) - if err != nil { - return nil, err - } - - return db, nil -} - func closeDBConnection(d *gorm.DB) { db, err := d.DB() if err != nil { diff --git a/scripts/db.go b/scripts/db.go index fb51a6d..c28db59 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -10,7 +10,7 @@ import ( migrate "github.com/rubenv/sql-migrate" "github.com/sirupsen/logrus" "github.com/source-academy/stories-backend/internal/config" - "gorm.io/gorm" + "github.com/source-academy/stories-backend/internal/database" ) const ( @@ -36,22 +36,22 @@ func main() { panic(err) } - var connector func(config.DatabaseConfig) (*gorm.DB, error) - // Check for command line arguments flag.Parse() switch flag.Arg(0) { case "drop", "create": - connector = connectAnonDB + // We need to connect anonymously in order + // to drop or create the database. + conf.Database.DatabaseName = "" case "migrate", "rollback", "status": - connector = connectDB + // Do nothing default: logrus.Errorln("Invalid command") return } // Connect to the database - d, err := connector(*conf.Database) + d, err := database.Connect(conf.Database) if err != nil { logrus.Errorln(err) panic(err) From b1cfc0c0b425c510a9421ab6f36d83dc22076b48 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:31:21 +0800 Subject: [PATCH 05/16] Refactor to use common DB "close" helper --- scripts/create_db.go | 17 ----------------- scripts/db.go | 7 ++++++- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 503b3f9..56b7e8d 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -8,23 +8,6 @@ import ( "gorm.io/gorm" ) -func closeDBConnection(d *gorm.DB) { - db, err := d.DB() - if err != nil { - panic(err) - } - - dbName, err := getConnectedDBName(d) - if err != nil { - panic(err) - } - fmt.Println(blueSandwich, "Closing connection with database", dbName+".") - - if err := db.Close(); err != nil { - panic(err) - } -} - func createDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { if dbconf.DatabaseName == "" { return errors.New("Failed to create database: no database name provided.") diff --git a/scripts/db.go b/scripts/db.go index c28db59..06a4cd4 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -56,7 +56,12 @@ func main() { logrus.Errorln(err) panic(err) } - defer closeDBConnection(d) + defer (func() { + // Ignore non-critical error + dbName, _ := getConnectedDBName(d) + fmt.Println(blueSandwich, "Closing connection with database", dbName+".") + database.Close(d) + })() dbName, err := getConnectedDBName(d) if err != nil { From dcaaa61dd40b4bccd88d3695d61ba599fd044b43 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:33:14 +0800 Subject: [PATCH 06/16] Rename `d` to `dbConn` Makes the name more descriptive. --- scripts/db.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/db.go b/scripts/db.go index 06a4cd4..bc6e639 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -51,19 +51,19 @@ func main() { } // Connect to the database - d, err := database.Connect(conf.Database) + dbConn, err := database.Connect(conf.Database) if err != nil { logrus.Errorln(err) panic(err) } defer (func() { // Ignore non-critical error - dbName, _ := getConnectedDBName(d) + dbName, _ := getConnectedDBName(dbConn) fmt.Println(blueSandwich, "Closing connection with database", dbName+".") - database.Close(d) + database.Close(dbConn) })() - dbName, err := getConnectedDBName(d) + dbName, err := getConnectedDBName(dbConn) if err != nil { panic(err) } @@ -71,35 +71,35 @@ func main() { switch flag.Arg(0) { case "drop": - err := dropDB(d, conf.Database) + err := dropDB(dbConn, conf.Database) if err != nil { logrus.Errorln(err) panic(err) } fmt.Println(greenTick, "Dropped database:", conf.Database.DatabaseName) case "create": - err := createDB(d, conf.Database) + err := createDB(dbConn, conf.Database) if err != nil { logrus.Errorln(err) panic(err) } fmt.Println(greenTick, "Created database:", conf.Database.DatabaseName) case "migrate": - db, err := d.DB() + db, err := dbConn.DB() if err != nil { logrus.Errorln(err) panic(err) } migrateDB(db) case "rollback": - db, err := d.DB() + db, err := dbConn.DB() if err != nil { logrus.Errorln(err) panic(err) } rollbackDB(db) case "status": - db, err := d.DB() + db, err := dbConn.DB() if err != nil { logrus.Errorln(err) panic(err) From 34a5d5811f49a5ee2629a3482e54b999df20031f Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:37:20 +0800 Subject: [PATCH 07/16] Add comment --- scripts/db.go | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/db.go b/scripts/db.go index bc6e639..4aff67a 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -56,6 +56,7 @@ func main() { logrus.Errorln(err) panic(err) } + // Remember to close the connection defer (func() { // Ignore non-critical error dbName, _ := getConnectedDBName(dbConn) From 3f7dbc42d20330f6172885ef9c9f522efc4412fa Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:42:12 +0800 Subject: [PATCH 08/16] Replace string with constants Prevents bugs. --- scripts/db.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/db.go b/scripts/db.go index 4aff67a..e94d0e3 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -16,6 +16,12 @@ import ( const ( defaultMaxMigrateSteps = 0 // no limit defaultMaxRollbackSteps = 1 + + dropCmd = "drop" + createCmd = "create" + migrateCmd = "migrate" + rollbackCmd = "rollback" + statusCmd = "status" ) var ( @@ -39,11 +45,11 @@ func main() { // Check for command line arguments flag.Parse() switch flag.Arg(0) { - case "drop", "create": + case dropCmd, createCmd: // We need to connect anonymously in order // to drop or create the database. conf.Database.DatabaseName = "" - case "migrate", "rollback", "status": + case migrateCmd, rollbackCmd, statusCmd: // Do nothing default: logrus.Errorln("Invalid command") @@ -71,35 +77,35 @@ func main() { fmt.Println(blueSandwich, "Connected to database", dbName+".") switch flag.Arg(0) { - case "drop": + case dropCmd: err := dropDB(dbConn, conf.Database) if err != nil { logrus.Errorln(err) panic(err) } fmt.Println(greenTick, "Dropped database:", conf.Database.DatabaseName) - case "create": + case createCmd: err := createDB(dbConn, conf.Database) if err != nil { logrus.Errorln(err) panic(err) } fmt.Println(greenTick, "Created database:", conf.Database.DatabaseName) - case "migrate": + case migrateCmd: db, err := dbConn.DB() if err != nil { logrus.Errorln(err) panic(err) } migrateDB(db) - case "rollback": + case rollbackCmd: db, err := dbConn.DB() if err != nil { logrus.Errorln(err) panic(err) } rollbackDB(db) - case "status": + case statusCmd: db, err := dbConn.DB() if err != nil { logrus.Errorln(err) From 5a3f5d0cd47b11de8897897a639a08969b6185d5 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:44:52 +0800 Subject: [PATCH 09/16] Rename `getConnectedDBName` to `getDBName` --- scripts/create_db.go | 2 +- scripts/db.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 56b7e8d..243089a 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -48,7 +48,7 @@ func dropDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { return nil } -func getConnectedDBName(db *gorm.DB) (string, error) { +func getDBName(db *gorm.DB) (string, error) { var dbName string err := db.Raw("SELECT current_database();").Scan(&dbName).Error return dbName, err diff --git a/scripts/db.go b/scripts/db.go index e94d0e3..379a6da 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -65,12 +65,12 @@ func main() { // Remember to close the connection defer (func() { // Ignore non-critical error - dbName, _ := getConnectedDBName(dbConn) + dbName, _ := getDBName(dbConn) fmt.Println(blueSandwich, "Closing connection with database", dbName+".") database.Close(dbConn) })() - dbName, err := getConnectedDBName(dbConn) + dbName, err := getDBName(dbConn) if err != nil { panic(err) } From 2c1efefaeb0cd3f8b97f17c8f1c78b87bd8e04aa Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:05:50 +0800 Subject: [PATCH 10/16] Change createDB signature Hides implementation details of the config object as the function only needs to be aware of the database name to create, not how it is derived from. --- scripts/create_db.go | 14 +++++++------- scripts/db.go | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 243089a..5c82d34 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -8,14 +8,14 @@ import ( "gorm.io/gorm" ) -func createDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { - if dbconf.DatabaseName == "" { +func createDB(db *gorm.DB, dbName string) error { + if dbName == "" { return errors.New("Failed to create database: no database name provided.") } // check if db exists - fmt.Println(yellowChevron, "Checking if database", dbconf.DatabaseName, "exists.") - result := db.Raw("SELECT * FROM pg_database WHERE datname = ?", dbconf.DatabaseName) + fmt.Println(yellowChevron, "Checking if database", dbName, "exists.") + result := db.Raw("SELECT * FROM pg_database WHERE datname = ?", dbName) if result.Error != nil { return result.Error } @@ -23,9 +23,9 @@ func createDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { // if not exists create it rec := make(map[string]interface{}) if result.Find(rec); len(rec) == 0 { - fmt.Println(yellowChevron, "Database", dbconf.DatabaseName, "does not exist. Creating...") + fmt.Println(yellowChevron, "Database", dbName, "does not exist. Creating...") - create_command := fmt.Sprintf("CREATE DATABASE %s", dbconf.DatabaseName) + create_command := fmt.Sprintf("CREATE DATABASE %s", dbName) result := db.Exec(create_command) if result.Error != nil { @@ -33,7 +33,7 @@ func createDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { } } - fmt.Println(yellowChevron, "Database", dbconf.DatabaseName, "exists.") + fmt.Println(yellowChevron, "Database", dbName, "exists.") return nil } diff --git a/scripts/db.go b/scripts/db.go index 379a6da..75c986d 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -42,6 +42,8 @@ func main() { panic(err) } + targetDBName := conf.Database.DatabaseName + // Check for command line arguments flag.Parse() switch flag.Arg(0) { @@ -83,14 +85,14 @@ func main() { logrus.Errorln(err) panic(err) } - fmt.Println(greenTick, "Dropped database:", conf.Database.DatabaseName) + fmt.Println(greenTick, "Dropped database:", targetDBName) case createCmd: - err := createDB(dbConn, conf.Database) + err := createDB(dbConn, targetDBName) if err != nil { logrus.Errorln(err) panic(err) } - fmt.Println(greenTick, "Created database:", conf.Database.DatabaseName) + fmt.Println(greenTick, "Created database:", targetDBName) case migrateCmd: db, err := dbConn.DB() if err != nil { From 8d7dc74c32f460aa46e01fd90f00af4a7400fd16 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:07:45 +0800 Subject: [PATCH 11/16] Change dropDB signature Similar to createDB, this improves abstraction. --- scripts/create_db.go | 5 ++--- scripts/db.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 5c82d34..40a7161 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/source-academy/stories-backend/internal/config" "gorm.io/gorm" ) @@ -38,8 +37,8 @@ func createDB(db *gorm.DB, dbName string) error { return nil } -func dropDB(db *gorm.DB, dbconf *config.DatabaseConfig) error { - drop_command := fmt.Sprintf("DROP DATABASE IF EXISTS %s;", dbconf.DatabaseName) +func dropDB(db *gorm.DB, dbName string) error { + drop_command := fmt.Sprintf("DROP DATABASE IF EXISTS %s;", dbName) result := db.Exec(drop_command) if result.Error != nil { return result.Error diff --git a/scripts/db.go b/scripts/db.go index 75c986d..a8dbe09 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -80,7 +80,7 @@ func main() { switch flag.Arg(0) { case dropCmd: - err := dropDB(dbConn, conf.Database) + err := dropDB(dbConn, targetDBName) if err != nil { logrus.Errorln(err) panic(err) From 73b2baaf0ba6711561bf3a60cd12482848921d0c Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:12:55 +0800 Subject: [PATCH 12/16] Refactor script setup to separate function Improves single responsibility. --- scripts/db.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/db.go b/scripts/db.go index a8dbe09..6fcb463 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -34,7 +34,7 @@ var ( }) ) -func main() { +func setupScript() (string, *config.DatabaseConfig) { // Load configuration conf, err := config.LoadFromEnvironment() if err != nil { @@ -55,11 +55,21 @@ func main() { // Do nothing default: logrus.Errorln("Invalid command") + return targetDBName, nil + } + + return targetDBName, conf.Database +} + +func main() { + targetDBName, dbConfig := setupScript() + if dbConfig == nil { + // Invalid configuration return } // Connect to the database - dbConn, err := database.Connect(conf.Database) + dbConn, err := database.Connect(dbConfig) if err != nil { logrus.Errorln(err) panic(err) From fda1fe2304175dd4f7275486908e3267ef79a653 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:14:45 +0800 Subject: [PATCH 13/16] Simplify dropDB implementation --- scripts/create_db.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 40a7161..3c8d0bc 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -39,12 +39,8 @@ func createDB(db *gorm.DB, dbName string) error { func dropDB(db *gorm.DB, dbName string) error { drop_command := fmt.Sprintf("DROP DATABASE IF EXISTS %s;", dbName) - result := db.Exec(drop_command) - if result.Error != nil { - return result.Error - } - - return nil + err := db.Exec(drop_command).Error + return err } func getDBName(db *gorm.DB) (string, error) { From b206fe38d46fe9f330e3862c5ab12d814512288f Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:18:25 +0800 Subject: [PATCH 14/16] Refactor createDB implementation * Move happy path to outside if condition * Simplify error handling * Update logging behavior --- scripts/create_db.go | 20 ++++++++++---------- scripts/db.go | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index 3c8d0bc..c487736 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -21,19 +21,19 @@ func createDB(db *gorm.DB, dbName string) error { // if not exists create it rec := make(map[string]interface{}) - if result.Find(rec); len(rec) == 0 { - fmt.Println(yellowChevron, "Database", dbName, "does not exist. Creating...") - - create_command := fmt.Sprintf("CREATE DATABASE %s", dbName) - result := db.Exec(create_command) - - if result.Error != nil { - return result.Error - } + if result.Find(rec); len(rec) != 0 { + fmt.Println(yellowChevron, "Database", dbName, "exists.") + return nil } - fmt.Println(yellowChevron, "Database", dbName, "exists.") + fmt.Println(yellowChevron, "Database", dbName, "does not exist. Creating...") + create_command := fmt.Sprintf("CREATE DATABASE %s", dbName) + err := db.Exec(create_command).Error + if err != nil { + return err + } + fmt.Println(greenTick, "Created database:", dbName) return nil } diff --git a/scripts/db.go b/scripts/db.go index 6fcb463..1a44f5e 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -102,7 +102,6 @@ func main() { logrus.Errorln(err) panic(err) } - fmt.Println(greenTick, "Created database:", targetDBName) case migrateCmd: db, err := dbConn.DB() if err != nil { From 487cc93b9b2e9662424b526ddab610b766ab67e7 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:27:41 +0800 Subject: [PATCH 15/16] Update log colors --- scripts/create_db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_db.go b/scripts/create_db.go index c487736..6be35ef 100644 --- a/scripts/create_db.go +++ b/scripts/create_db.go @@ -22,7 +22,7 @@ func createDB(db *gorm.DB, dbName string) error { // if not exists create it rec := make(map[string]interface{}) if result.Find(rec); len(rec) != 0 { - fmt.Println(yellowChevron, "Database", dbName, "exists.") + fmt.Println(greenTick, "Database", dbName, "already exists.") return nil } From e48b4a847892e872c2c0482117dca3efb8e00d41 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:29:48 +0800 Subject: [PATCH 16/16] Remove unnecessary code --- scripts/db.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/db.go b/scripts/db.go index 1a44f5e..087afa0 100644 --- a/scripts/db.go +++ b/scripts/db.go @@ -76,9 +76,7 @@ func main() { } // Remember to close the connection defer (func() { - // Ignore non-critical error - dbName, _ := getDBName(dbConn) - fmt.Println(blueSandwich, "Closing connection with database", dbName+".") + fmt.Println(blueSandwich, "Closing connection...") database.Close(dbConn) })()