Skip to content

Commit 8c0eb24

Browse files
committed
Merge branch 'develop' into pg-delta
2 parents 9baac15 + 9b9b5a2 commit 8c0eb24

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

internal/db/diff/pgdelta.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package diff
33
import (
44
"bytes"
55
"context"
6+
_ "embed"
67
"strings"
78

89
"github.com/docker/docker/api/types/container"

internal/utils/connect.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,22 @@ func ConnectByUrl(ctx context.Context, url string, options ...func(*pgx.ConnConf
164164
}
165165
cc.Fallbacks = fallbacks
166166
})
167-
return pgxv5.Connect(ctx, url, options...)
167+
conn, err := pgxv5.Connect(ctx, url, options...)
168+
var pgErr *pgconn.PgError
169+
if errors.As(err, &pgErr) {
170+
if strings.Contains(pgErr.Message, "connect: connection refused") {
171+
CmdSuggestion = fmt.Sprintf("Make sure your local IP is allowed in Network Restrictions and Network Bans.\n%s/project/_/database/settings", CurrentProfile.DashboardURL)
172+
} else if strings.Contains(pgErr.Message, "SSL connection is required") && viper.GetBool("DEBUG") {
173+
CmdSuggestion = "SSL connection is not supported with --debug flag"
174+
} else if strings.Contains(pgErr.Message, "SCRAM exchange: Wrong password") || strings.Contains(pgErr.Message, "failed SASL auth") {
175+
// password authentication failed for user / invalid SCRAM server-final-message received from server
176+
CmdSuggestion = "Try setting the SUPABASE_DB_PASSWORD environment variable"
177+
} else if strings.Contains(pgErr.Message, "connect: no route to host") || strings.Contains(pgErr.Message, "Tenant or user not found") {
178+
// Assumes IPv6 check has been performed before this
179+
CmdSuggestion = "Make sure your project exists on profile: " + CurrentProfile.Name
180+
}
181+
}
182+
return conn, err
168183
}
169184

170185
const (

0 commit comments

Comments
 (0)