mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-14 00:43:48 +01:00
Postgres defaults to unix socket (#230)
This commit is contained in:
parent
fb17e8eeca
commit
81fe01b34f
2 changed files with 25 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/amacneil/dbmate/pkg/dbmate"
|
||||
|
|
@ -48,7 +49,14 @@ func connectionString(u *url.URL) string {
|
|||
|
||||
// default hostname
|
||||
if hostname == "" {
|
||||
hostname = "localhost"
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
query.Set("host", "/var/run/postgresql")
|
||||
case "darwin", "freebsd", "dragonfly", "openbsd", "netbsd":
|
||||
query.Set("host", "/tmp")
|
||||
default:
|
||||
hostname = "localhost"
|
||||
}
|
||||
}
|
||||
|
||||
// host param overrides url hostname
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue