Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ed9a49

Browse files
committed
fix: avoid using pg_dump 17.0 or higher when generating schema
1 parent62c7430 commit9ed9a49

File tree

1 file changed

+19
-18
lines changed
  • coderd/database/dbtestutil

1 file changed

+19
-18
lines changed

‎coderd/database/dbtestutil/db.go‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"regexp"
13-
"strconv"
1413
"strings"
1514
"testing"
1615
"time"
@@ -206,7 +205,7 @@ func DumpOnFailure(t testing.TB, connectionURL string) {
206205
outPath:=filepath.Join(cwd,snakeCaseName+"."+timeSuffix+".test.sql")
207206
dump,err:=PGDump(connectionURL)
208207
iferr!=nil {
209-
t.Errorf("dump on failure: failed to run pg_dump: %s",err.Error())
208+
t.Errorf("dump on failure: failed to run pg_dump")
210209
return
211210
}
212211
iferr:=os.WriteFile(outPath,normalizeDump(dump),0o600);err!=nil {
@@ -251,26 +250,28 @@ func PGDump(dbURL string) ([]byte, error) {
251250
returnstdout.Bytes(),nil
252251
}
253252

254-
constminimumPostgreSQLVersion=13
253+
constpostgresImageSha="sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
255254

256255
// PGDumpSchemaOnly is for use by gen/dump only.
257256
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
258257
funcPGDumpSchemaOnly(dbURLstring) ([]byte,error) {
259258
hasPGDump:=false
260-
if_,err:=exec.LookPath("pg_dump");err==nil {
261-
out,err:=exec.Command("pg_dump","--version").Output()
262-
iferr==nil {
263-
// Parse output:
264-
// pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
265-
parts:=strings.Split(string(out)," ")
266-
iflen(parts)>2 {
267-
version,err:=strconv.Atoi(strings.Split(parts[2],".")[0])
268-
iferr==nil&&version>=minimumPostgreSQLVersion {
269-
hasPGDump=true
270-
}
271-
}
272-
}
273-
}
259+
// TODO: Temporarily pin pg_dump to the docker image until
260+
// https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
261+
// if _, err := exec.LookPath("pg_dump"); err == nil {
262+
// out, err := exec.Command("pg_dump", "--version").Output()
263+
// if err == nil {
264+
// // Parse output:
265+
// // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
266+
// parts := strings.Split(string(out), " ")
267+
// if len(parts) > 2 {
268+
// version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
269+
// if err == nil && version >= minimumPostgreSQLVersion {
270+
// hasPGDump = true
271+
// }
272+
// }
273+
// }
274+
// }
274275

275276
cmdArgs:= []string{
276277
"pg_dump",
@@ -295,7 +296,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
295296
"run",
296297
"--rm",
297298
"--network=host",
298-
fmt.Sprintf("%s:%d",postgresImage,minimumPostgreSQLVersion),
299+
fmt.Sprintf("%s@%d",postgresImage,postgresImageSha),
299300
},cmdArgs...)
300301
}
301302
cmd:=exec.Command(cmdArgs[0],cmdArgs[1:]...)//#nosec

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp