mirror of https://github.com/pressly/goose.git
Autoparse postgres urls
parent
f787354860
commit
6f67731d6a
10
dbconf.go
10
dbconf.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/bmizerany/pq"
|
||||
"github.com/kylelemons/go-gypsy/yaml"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -40,6 +41,15 @@ func MakeDBConf() (*DBConf, error) {
|
|||
}
|
||||
open = os.ExpandEnv(open)
|
||||
|
||||
// Automatically parse postgres urls
|
||||
if drv == "postgres" {
|
||||
parsed_open, parse_err := pq.ParseURL(open)
|
||||
// Assumption: If we can parse the URL, we should
|
||||
if parse_err == nil && parsed_open != "" {
|
||||
open = parsed_open
|
||||
}
|
||||
}
|
||||
|
||||
return &DBConf{
|
||||
MigrationsDir: path.Join(*dbPath, "migrations"),
|
||||
Env: *dbEnv,
|
||||
|
|
Loading…
Reference in New Issue