Skip to content

Commit 03d2492

Browse files
committed
chore: switch to use fixturize binary instead library
preparing for Rust rewrite
1 parent 4255971 commit 03d2492

4 files changed

Lines changed: 59 additions & 212 deletions

File tree

cmd/fixturize.go

Lines changed: 50 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package cmd
33
import (
44
"fmt"
55
"os"
6-
"path/filepath"
6+
"os/exec"
7+
"strconv"
78

8-
"github.com/boringsql/fixturize/fixturize"
99
"github.com/boringsql/regresql/regresql"
1010
"github.com/spf13/cobra"
1111
)
@@ -100,64 +100,49 @@ func init() {
100100
fixturizeApplyCmd.Flags().BoolVar(&fzApplyDisableTriggers, "disable-triggers", false, "Disable triggers during insert (uses replica mode)")
101101
}
102102

103-
func runFixturizeExtract(cmd *cobra.Command, args []string) error {
104-
db, err := fixturize.OpenDB(fzExtractConn)
105-
if err != nil {
106-
return fmt.Errorf("failed to connect to database: %w", err)
103+
func checkFixturizeBinary() error {
104+
if _, err := exec.LookPath("fixturize"); err != nil {
105+
return fmt.Errorf("fixturize binary not found in PATH\nSee https://github.com/boringSQL/fixturize for install instructions")
107106
}
108-
defer db.Close()
107+
return nil
108+
}
109109

110-
options := &fixturize.ExtractOptions{
111-
Connection: fzExtractConn,
112-
Root: fzExtractRoot,
113-
Schema: fzExtractSchema,
114-
Output: fzExtractOutput,
115-
Limit: fzExtractLimit,
116-
Depth: fzExtractDepth,
117-
Include: parseCommaSeparatedFz(fzExtractInclude),
118-
Exclude: parseCommaSeparatedFz(fzExtractExclude),
119-
Mask: fzExtractMask,
120-
StatementTimeout: fzExtractStatementTimeout,
121-
DryRun: fzExtractDryRun,
110+
func runFixturizeExtract(cmd *cobra.Command, args []string) error {
111+
if err := checkFixturizeBinary(); err != nil {
112+
return err
122113
}
123-
124-
if !fzExtractDryRun && fzExtractOutput != "" {
125-
os.Remove(fzExtractOutput)
114+
fzArgs := []string{"extract", "--connection", fzExtractConn, "--root", fzExtractRoot}
115+
if fzExtractSchema != "" {
116+
fzArgs = append(fzArgs, "--schema", fzExtractSchema)
126117
}
127-
128-
extractor := fixturize.NewExtractor(db, options)
129-
result, err := extractor.Extract()
130-
if err != nil {
131-
return fmt.Errorf("extraction failed: %w", err)
118+
if fzExtractOutput != "" {
119+
fzArgs = append(fzArgs, "--output", fzExtractOutput)
132120
}
133-
134-
for _, w := range result.Warnings {
135-
fmt.Fprintf(os.Stderr, "Warning: %s\n", w)
121+
if fzExtractLimit > 0 {
122+
fzArgs = append(fzArgs, "--limit", strconv.Itoa(fzExtractLimit))
136123
}
137-
138-
if fzExtractDryRun {
139-
fmt.Println(string(result.JSON))
140-
return nil
124+
if fzExtractDepth > 0 {
125+
fzArgs = append(fzArgs, "--depth", strconv.Itoa(fzExtractDepth))
141126
}
142-
143-
outputPath := fzExtractOutput
144-
if outputPath == "" {
145-
outputPath = "extracted.json"
127+
if fzExtractInclude != "" {
128+
fzArgs = append(fzArgs, "--include", fzExtractInclude)
146129
}
147-
148-
dir := filepath.Dir(outputPath)
149-
if dir != "." && dir != "" {
150-
if err := os.MkdirAll(dir, 0755); err != nil {
151-
return fmt.Errorf("failed to create directory: %w", err)
152-
}
130+
if fzExtractExclude != "" {
131+
fzArgs = append(fzArgs, "--exclude", fzExtractExclude)
153132
}
154-
155-
if err := os.WriteFile(outputPath, result.JSON, 0644); err != nil {
156-
return fmt.Errorf("failed to write file: %w", err)
133+
for _, m := range fzExtractMask {
134+
fzArgs = append(fzArgs, "--mask", m)
157135
}
158-
159-
fmt.Printf("Fixture written to: %s\n", outputPath)
160-
return nil
136+
if fzExtractStatementTimeout > 0 {
137+
fzArgs = append(fzArgs, "--statement-timeout", strconv.Itoa(fzExtractStatementTimeout))
138+
}
139+
if fzExtractDryRun {
140+
fzArgs = append(fzArgs, "--dry-run")
141+
}
142+
c := exec.Command("fixturize", fzArgs...)
143+
c.Stdout = os.Stdout
144+
c.Stderr = os.Stderr
145+
return c.Run()
161146
}
162147

163148
func resolveApplyConnection() (string, error) {
@@ -175,69 +160,27 @@ func resolveApplyConnection() (string, error) {
175160
}
176161

177162
func runFixturizeApply(cmd *cobra.Command, args []string) error {
178-
connStr, err := resolveApplyConnection()
179-
if err != nil {
163+
if err := checkFixturizeBinary(); err != nil {
180164
return err
181165
}
182-
183-
db, err := fixturize.OpenDB(connStr)
184-
if err != nil {
185-
return fmt.Errorf("failed to connect to database: %w", err)
186-
}
187-
defer db.Close()
188-
189-
options := &fixturize.ApplyOptions{
190-
Connection: connStr,
191-
Fixture: args[0],
192-
Force: fzApplyForce,
193-
DryRun: fzApplyDryRun,
194-
DisableTriggers: fzApplyDisableTriggers,
195-
}
196-
197-
result, err := fixturize.ApplyFixtureFile(db, options)
166+
connStr, err := resolveApplyConnection()
198167
if err != nil {
199168
return err
200169
}
201-
202-
totalRows := 0
203-
for _, count := range result.RowsInserted {
204-
totalRows += count
170+
fzArgs := []string{"apply", "--connection", connStr}
171+
if fzApplyForce {
172+
fzArgs = append(fzArgs, "--force")
205173
}
206-
207-
fmt.Printf("Applied %d table(s), %d row(s) total\n", len(result.TablesApplied), totalRows)
208-
return nil
209-
}
210-
211-
func parseCommaSeparatedFz(s string) []string {
212-
if s == "" {
213-
return nil
214-
}
215-
var parts []string
216-
start := 0
217-
for i := 0; i < len(s); i++ {
218-
if s[i] == ',' {
219-
p := trimSpaceFz(s[start:i])
220-
if p != "" {
221-
parts = append(parts, p)
222-
}
223-
start = i + 1
224-
}
225-
}
226-
p := trimSpaceFz(s[start:])
227-
if p != "" {
228-
parts = append(parts, p)
229-
}
230-
return parts
231-
}
232-
233-
func trimSpaceFz(s string) string {
234-
start := 0
235-
end := len(s)
236-
for start < end && (s[start] == ' ' || s[start] == '\t') {
237-
start++
174+
if fzApplyDryRun {
175+
fzArgs = append(fzArgs, "--dry-run")
238176
}
239-
for end > start && (s[end-1] == ' ' || s[end-1] == '\t') {
240-
end--
177+
if fzApplyDisableTriggers {
178+
fzArgs = append(fzArgs, "--disable-triggers")
241179
}
242-
return s[start:end]
180+
fzArgs = append(fzArgs, args[0])
181+
c := exec.Command("fixturize", fzArgs...)
182+
c.Stdout = os.Stdout
183+
c.Stderr = os.Stderr
184+
return c.Run()
243185
}
186+

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/boringsql/regresql
33
go 1.25.6
44

55
require (
6-
github.com/boringsql/fixturize v0.3.0
76
github.com/boringsql/queries v1.6.1
87
github.com/jackc/pgx/v5 v5.8.0
98
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b

go.sum

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
1-
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
2-
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
3-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
4-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
5-
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
6-
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
7-
github.com/boringsql/fixturize v0.3.0 h1:2dEiL4DX22w7dfi94++7Ku6+jrygayhmrgJxCPbQB8w=
8-
github.com/boringsql/fixturize v0.3.0/go.mod h1:ACmNFJBq7a9yar4GYkNBh8sRWDBew/85BYdZCFfS6Vs=
91
github.com/boringsql/queries v1.6.1 h1:J/vImXYdisC+tlQNYt45O6CG6RX/MiIDR8j5/k6rQGk=
102
github.com/boringsql/queries v1.6.1/go.mod h1:zRQzwzZZ8e9o8PZWTKMxPqxTTg8hGvvinwitEBd0FCQ=
11-
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
12-
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
13-
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
14-
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
15-
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
16-
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
17-
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
18-
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
19-
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
20-
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
21-
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
22-
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
23-
github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA=
24-
github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
253
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
264
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
275
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
286
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
297
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
30-
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
31-
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
32-
github.com/docker/docker v28.5.1+incompatible h1:Bm8DchhSD2J6PsFzxC35TZo4TLGR2PdW/E69rU45NhM=
33-
github.com/docker/docker v28.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
34-
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
35-
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
36-
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
37-
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
38-
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
39-
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
40-
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
41-
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
42-
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
43-
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
44-
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
45-
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
46-
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
47-
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
48-
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
49-
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
508
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
519
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
5210
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
@@ -57,52 +15,18 @@ github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo=
5715
github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw=
5816
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
5917
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
60-
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
61-
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
6218
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6319
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
6420
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6521
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
66-
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
67-
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
68-
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
69-
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
7022
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b h1:Ga1nclDSe8gOw37MVLMhfu2QKWtD6gvtQ298zsKVh8g=
7123
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
72-
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
73-
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
74-
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
75-
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
76-
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
77-
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
78-
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
79-
github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko=
80-
github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs=
81-
github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
82-
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
83-
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
84-
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
85-
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
86-
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
87-
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
88-
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
89-
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
90-
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
91-
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
9224
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
93-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
94-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9525
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
9626
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
97-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
98-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
9927
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
10028
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
10129
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
102-
github.com/shirou/gopsutil/v4 v4.25.6 h1:kLysI2JsKorfaFPcYmcJqbzROzsBWEOAtw6A7dIfqXs=
103-
github.com/shirou/gopsutil/v4 v4.25.6/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c=
104-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
105-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
10630
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
10731
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
10832
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
@@ -113,27 +37,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
11337
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
11438
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
11539
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
116-
github.com/testcontainers/testcontainers-go v0.40.0 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU=
117-
github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY=
118-
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
119-
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
120-
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
121-
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
122-
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
123-
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
124-
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
125-
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
126-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
127-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
128-
go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms=
129-
go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g=
130-
go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g=
131-
go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc=
132-
go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw=
133-
go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA=
13440
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
135-
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
136-
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
13741
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
13842
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
13943
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=

regresql/snapshot_build.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strings"
1313
"time"
1414

15-
"github.com/boringsql/fixturize/fixturize"
1615
)
1716

1817
type (
@@ -171,7 +170,7 @@ func BuildSnapshot(basePgUri string, root string, opts SnapshotBuildOptions) (*s
171170
if opts.Verbose {
172171
fmt.Printf("Applying %d fixturize fixture(s)...\n", len(opts.Fixturize))
173172
}
174-
fixturizeUsed, err = applyFixturizeFiles(db, root, opts.Fixturize, opts.DisableTriggers, opts.Verbose)
173+
fixturizeUsed, err = applyFixturizeFiles(tempDB.PgUri, root, opts.Fixturize, opts.DisableTriggers, opts.Verbose)
175174
if err != nil {
176175
return nil, err
177176
}
@@ -306,7 +305,7 @@ func GetSnapshotFixturize(cfg *SnapshotConfig) []string {
306305
return cfg.Fixturize
307306
}
308307

309-
func applyFixturizeFiles(db *sql.DB, root string, files []string, disableTriggers, verbose bool) ([]string, error) {
308+
func applyFixturizeFiles(pgUri string, root string, files []string, disableTriggers, verbose bool) ([]string, error) {
310309
var applied []string
311310
for _, f := range files {
312311
path := f
@@ -316,12 +315,14 @@ func applyFixturizeFiles(db *sql.DB, root string, files []string, disableTrigger
316315
if verbose {
317316
fmt.Printf(" Fixturize: %s\n", f)
318317
}
319-
opts := &fixturize.ApplyOptions{
320-
Fixture: path,
321-
DisableTriggers: disableTriggers,
318+
fzArgs := []string{"apply", "--connection", pgUri}
319+
if disableTriggers {
320+
fzArgs = append(fzArgs, "--disable-triggers")
322321
}
323-
if _, err := fixturize.ApplyFixtureFile(db, opts); err != nil {
324-
return nil, fmt.Errorf("fixturize %q: %w", f, err)
322+
fzArgs = append(fzArgs, path)
323+
cmd := exec.Command("fixturize", fzArgs...)
324+
if out, err := cmd.CombinedOutput(); err != nil {
325+
return nil, fmt.Errorf("fixturize %q: %w\n%s", f, err, out)
325326
}
326327
applied = append(applied, f)
327328
}

0 commit comments

Comments
 (0)