Add environ variable to configure the postgres DB

This commit is contained in:
David Dworken 2022-10-15 09:21:10 -07:00
parent a61e56a01b
commit 38c185c9f9

View File

@ -352,7 +352,11 @@ func OpenDB() (*gorm.DB, error) {
return db, nil return db, nil
} }
db, err := gorm.Open(postgres.Open(PostgresDb), &gorm.Config{}) postgresDb := PostgresDb
if os.Getenv("HISHTORY_POSTGRES_DB") != "" {
postgresDb = os.Getenv("HISHTORY_POSTGRES_DB")
}
db, err := gorm.Open(postgres.Open(postgresDb), &gorm.Config{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to connect to the DB: %v", err) return nil, fmt.Errorf("failed to connect to the DB: %v", err)
} }