Autoparse postgres urls

pull/2/head
Josh Bleecher Snyder 2013-01-10 12:03:02 -08:00
parent f787354860
commit 6f67731d6a
1 changed files with 10 additions and 0 deletions

View File

@ -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,