From f76b70af81de6a441962e6b0ccbec84646f91741 Mon Sep 17 00:00:00 2001 From: luisserra Date: Mon, 28 Mar 2022 21:57:06 +0100 Subject: [PATCH] chore: move db var to savePgsql function --- cmd/database.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/database.go b/cmd/database.go index 3e170f0..3aaa3f6 100644 --- a/cmd/database.go +++ b/cmd/database.go @@ -20,6 +20,7 @@ type PsqlConnInfo struct { Password string Schema string } + func getPsqlConnInfo() (PsqlConnInfo, error) { var host string if value := viper.GetString("PGSQL_HOST"); value != "" { @@ -107,6 +108,8 @@ func savePgsql(jsonInfo string) { exitWithError(err) } + var db *gorm.DB + if PsqlConnInfo.Schema == "" { db, err = gorm.Open(postgres.Open(PsqlConnInfo.toString()), &gorm.Config{}) } else {