You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Surface psql errors and abort cleanly on failed Postgres restore
Run psql with ON_ERROR_STOP=1 and --single-transaction so a restore that
hits an error rolls back instead of leaving a half-applied dump, and
capture psql's stderr so the failure message reports the underlying
cause and a schema-compatibility hint rather than a generic
"couldn't connect".
Co-Authored-By: Claude <noreply@anthropic.com>
returnerrors.Errorf("Couldn't connect to the target database. Please check that the proxy is running on port %s\n\n%s", target.Port, err.Error())
241
+
detail:=strings.TrimSpace(stderr.String())
242
+
ifdetail=="" {
243
+
detail=err.Error()
244
+
}
245
+
returnerrors.Errorf("Restore failed. Check that the proxy is running on port %s and that the dump is compatible with the target schema.\n\n%s", target.Port, detail)
240
246
}
241
247
} else {
242
248
// Attempt to create the database in case it doesn't exist
returnerrors.Errorf("Couldn't connect to the target database. Please check that your database server running on port %s\n\n%s", target.Port, err.Error())
258
+
detail:=strings.TrimSpace(stderr.String())
259
+
ifdetail=="" {
260
+
detail=err.Error()
261
+
}
262
+
returnerrors.Errorf("Restore failed. Check that your database server is running on port %s and that the dump is compatible with the target schema.\n\n%s", target.Port, detail)
0 commit comments