Skip to content

Commit

Permalink
fix: --host localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Dec 9, 2021
1 parent ea41e84 commit c44acfe
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions internal/db/branch/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Run(branch string) error {
var dumpBuf bytes.Buffer
if err := func() error {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "pg_dump --username postgres -d '" + currBranch + "'",
"sh", "-c", "pg_dump --username postgres --host localhost --dbname '" + currBranch + "'",
})
if err != nil {
return err
Expand All @@ -67,7 +67,7 @@ func Run(branch string) error {

if err := func() error {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "createdb --username postgres '" + branch + "' && psql --username postgres --dbname '" + branch + `' <<'EOSQL'
"sh", "-c", "createdb --username postgres --host localhost '" + branch + "' && psql --username postgres --host localhost --dbname '" + branch + `' <<'EOSQL'
BEGIN;
` + dumpBuf.String() + `
COMMIT;
Expand Down
4 changes: 2 additions & 2 deletions internal/db/branch/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func Run(branch string) error {
{
// https://dba.stackexchange.com/a/11895
out, err := utils.DockerExec(context.Background(), utils.DbId, []string{
"sh", "-c", "psql --username postgres <<'EOSQL' " +
"&& dropdb --force --username postgres '" + branch + `'
"sh", "-c", "psql --username postgres --host localhost <<'EOSQL' " +
"&& dropdb --force --username postgres --host localhost '" + branch + `'
BEGIN;
` + fmt.Sprintf(utils.TerminateDbSqlFmt, branch) + `
COMMIT;
Expand Down
6 changes: 3 additions & 3 deletions internal/db/changes/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func run(p *tea.Program) error {
out, err := utils.DockerExec(
ctx,
utils.DbId,
[]string{"createdb", "--username", "postgres", utils.ShadowDbName},
[]string{"createdb", "--username", "postgres", "--host", "localhost", utils.ShadowDbName},
)
if err != nil {
return err
Expand All @@ -177,7 +177,7 @@ func run(p *tea.Program) error {
}

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres --dbname '" + utils.ShadowDbName + `' <<'EOSQL'
"sh", "-c", "psql --username postgres --host localhost --dbname '" + utils.ShadowDbName + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -221,7 +221,7 @@ EOSQL
out, err := utils.DockerExec(
ctx,
utils.DbId,
[]string{"dropdb", "--username", "postgres", utils.ShadowDbName},
[]string{"dropdb", "--username", "postgres", "--host", "localhost", utils.ShadowDbName},
)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions internal/db/commit/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func run(p *tea.Program, name string) error {
out, err := utils.DockerExec(
ctx,
utils.DbId,
[]string{"createdb", "--username", "postgres", utils.ShadowDbName},
[]string{"createdb", "--username", "postgres", "--host", "localhost", utils.ShadowDbName},
)
if err != nil {
return err
Expand All @@ -178,7 +178,7 @@ func run(p *tea.Program, name string) error {
}

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres --dbname '" + utils.ShadowDbName + `' <<'EOSQL'
"sh", "-c", "psql --username postgres --host localhost --dbname '" + utils.ShadowDbName + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -224,7 +224,7 @@ EOSQL
out, err := utils.DockerExec(
ctx,
utils.DbId,
[]string{"dropdb", "--username", "postgres", utils.ShadowDbName},
[]string{"dropdb", "--username", "postgres", "--host", "localhost", utils.ShadowDbName},
)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions internal/db/remote/commit/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func run(p *tea.Program, url string) error {
}

out, err := utils.DockerExec(ctx, dbId, []string{
"sh", "-c", `psql --username postgres --dbname postgres <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname postgres <<'EOSQL'
BEGIN;
` + string(globalsSql) + `
COMMIT;
Expand All @@ -296,7 +296,7 @@ EOSQL
}

out, err := utils.DockerExec(ctx, dbId, []string{
"sh", "-c", `psql --username postgres --dbname postgres <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname postgres <<'EOSQL'
BEGIN;
` + string(extensionsSql) + `
COMMIT;
Expand Down Expand Up @@ -325,7 +325,7 @@ EOSQL
}

out, err := utils.DockerExec(ctx, dbId, []string{
"sh", "-c", `psql --username postgres --dbname postgres <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname postgres <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down
12 changes: 6 additions & 6 deletions internal/db/reset/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ func run(p *tea.Program) (err error) {
{
// https://dba.stackexchange.com/a/11895
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres <<'EOSQL' " +
"&& dropdb --force --username postgres '" + currBranch + "' " +
"&& createdb --username postgres '" + currBranch + `'
"sh", "-c", "psql --username postgres --host localhost <<'EOSQL' " +
"&& dropdb --force --username postgres --host localhost '" + currBranch + "' " +
"&& createdb --username postgres --host localhost '" + currBranch + `'
BEGIN;
` + fmt.Sprintf(utils.TerminateDbSqlFmt, currBranch) + `
COMMIT;
Expand Down Expand Up @@ -197,7 +197,7 @@ EOSQL
return err
} else {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres --dbname '" + currBranch + `' <<'EOSQL'
"sh", "-c", "psql --username postgres --host localhost --dbname '" + currBranch + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -231,7 +231,7 @@ EOSQL
}

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres --dbname '" + currBranch + `' <<'EOSQL'
"sh", "-c", "psql --username postgres --host localhost --dbname '" + currBranch + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -259,7 +259,7 @@ EOSQL
return err
} else {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "psql --username postgres --dbname '" + currBranch + `' <<'EOSQL'
"sh", "-c", "psql --username postgres --host localhost --dbname '" + currBranch + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down
14 changes: 7 additions & 7 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func run(p *tea.Program) error {

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "until pg_isready --host $(hostname --ip-address); do sleep 0.1; done " +
`&& psql --username postgres <<'EOSQL'
`&& psql --username postgres --host localhost <<'EOSQL'
BEGIN;
` + string(globalsSql) + `
COMMIT;
Expand Down Expand Up @@ -496,7 +496,7 @@ EOSQL
}

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "createdb --username postgres '" + branch.Name() + "' && psql --username postgres --dbname '" + branch.Name() + `' <<'EOSQL'
"sh", "-c", "createdb --username postgres --host localhost '" + branch.Name() + "' && psql --username postgres --host localhost --dbname '" + branch.Name() + `' <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -540,7 +540,7 @@ EOSQL

{
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "createdb --username postgres main",
"sh", "-c", "createdb --username postgres --host localhost main",
})
if err != nil {
_ = os.RemoveAll("supabase/.branches/main")
Expand All @@ -563,7 +563,7 @@ EOSQL
return err
} else {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", `psql --username postgres --dbname main <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname main <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -597,7 +597,7 @@ EOSQL
}

out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", `psql --username postgres --dbname main <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname main <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -625,7 +625,7 @@ EOSQL
return err
} else {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", `psql --username postgres --dbname main <<'EOSQL'
"sh", "-c", `psql --username postgres --host localhost --dbname main <<'EOSQL'
BEGIN;
` + string(content) + `
COMMIT;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func dumpBranches() {

if err := func() error {
out, err := utils.DockerExec(ctx, utils.DbId, []string{
"sh", "-c", "pg_dump --username postgres -d '" + branch.Name() + "'",
"sh", "-c", "pg_dump --username postgres --host localhost --dbname '" + branch.Name() + "'",
})
if err != nil {
return err
Expand Down

0 comments on commit c44acfe

Please sign in to comment.