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

Commite56e8f1

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

File tree

1 file changed

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

1 file changed

+18
-16
lines changed

‎coderd/database/dbtestutil/db.go‎

Lines changed: 18 additions & 16 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"
@@ -252,25 +251,28 @@ func PGDump(dbURL string) ([]byte, error) {
252251
}
253252

254253
constminimumPostgreSQLVersion=13
254+
constpostgresImageSha="sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
255255

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

275277
cmdArgs:= []string{
276278
"pg_dump",
@@ -295,7 +297,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
295297
"run",
296298
"--rm",
297299
"--network=host",
298-
fmt.Sprintf("%s:%d",postgresImage,minimumPostgreSQLVersion),
300+
fmt.Sprintf("%s:%d@%s",postgresImage,minimumPostgreSQLVersion,postgresImageSha),
299301
},cmdArgs...)
300302
}
301303
cmd:=exec.Command(cmdArgs[0],cmdArgs[1:]...)//#nosec

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp