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

Commitecc6d53

Browse files
fix: pin pg_dump version when generating schema for 2.24 (#19698)
Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com>
1 parentd7c4833 commitecc6d53

File tree

1 file changed

+21
-17
lines changed
  • coderd/database/dbtestutil

1 file changed

+21
-17
lines changed

‎coderd/database/dbtestutil/db.go‎

Lines changed: 21 additions & 17 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"
@@ -254,26 +253,31 @@ func PGDump(dbURL string) ([]byte, error) {
254253
returnstdout.Bytes(),nil
255254
}
256255

257-
constminimumPostgreSQLVersion=13
256+
const (
257+
minimumPostgreSQLVersion=13
258+
postgresImageSha="sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
259+
)
258260

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

278282
cmdArgs:= []string{
279283
"pg_dump",
@@ -298,7 +302,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
298302
"run",
299303
"--rm",
300304
"--network=host",
301-
fmt.Sprintf("%s:%d",postgresImage,minimumPostgreSQLVersion),
305+
fmt.Sprintf("%s:%d@%s",postgresImage,minimumPostgreSQLVersion,postgresImageSha),
302306
},cmdArgs...)
303307
}
304308
cmd:=exec.Command(cmdArgs[0],cmdArgs[1:]...)//#nosec

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp