Make pool and poolSong global variables
Build / build (push) Successful in 48s

This commit is contained in:
2026-05-26 20:54:12 +02:00
parent d152ec1f11
commit a446dad7b6
12 changed files with 253 additions and 258 deletions
+3 -13
View File
@@ -76,7 +76,9 @@ func ResetGameIdSeq() {
}
func createDb(host string, port string, user string, password string, dbname string) {
conninfo := fmt.Sprintf("host=%s port=%s user=%s password=%s sslmode=disable", host, port, user, password)
// Connect to the default postgres database to create new database
// In PostgreSQL, we need to connect to an existing database (postgres) to create a new one
conninfo := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=postgres sslmode=disable", host, port, user, password)
db, err := sql.Open("postgres", conninfo)
defer db.Close()
@@ -102,18 +104,6 @@ func Migrate_db(host string, port string, user string, password string, dbname s
logging.GetLogger().Error("Failed to open database for migration", zap.String("error", err.Error()))
}
_, err = db.Query("select * from game")
if err != nil {
logging.GetLogger().Warn("Game table not found, creating database", zap.String("error", err.Error()))
createDb(host, port, user, password, dbname)
db, err = sql.Open("postgres", migrationInfo)
if err != nil {
logging.GetLogger().Fatal("Failed to reconnect after database creation", zap.String("error", err.Error()))
}
}
driver, err := postgres.WithInstance(db, &postgres.Config{})
if err != nil {
logging.GetLogger().Error("Failed to create migration driver", zap.String("error", err.Error()))