mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-01-04 21:45:30 +01:00
Merge pull request #215 from prusnak/psql-unix-prefix
Enable "unix:" prefix for PostgreSQL connection string
This commit is contained in:
4
db/db.go
4
db/db.go
@@ -14,11 +14,11 @@ import (
|
||||
func Open(dsn string) (*bun.DB, error) {
|
||||
var db *bun.DB
|
||||
switch {
|
||||
case strings.HasPrefix(dsn, "postgres"):
|
||||
case strings.HasPrefix(dsn, "postgres://") || strings.HasPrefix(dsn, "postgresql://") || strings.HasPrefix(dsn, "unix://"):
|
||||
dbConn := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn)))
|
||||
db = bun.NewDB(dbConn, pgdialect.New())
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid database connection string %s, only postgres is supported", dsn)
|
||||
return nil, fmt.Errorf("Invalid database connection string %s, only (postgres|postgresql|unix):// is supported", dsn)
|
||||
}
|
||||
|
||||
db.AddQueryHook(bundebug.NewQueryHook(
|
||||
|
||||
Reference in New Issue
Block a user