Skip to content

Commit

Permalink
fix: handle version prefix in globals (#2701)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge authored Sep 21, 2024
1 parent a0a5d5f commit cd94f35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pkg/migration/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ func SeedGlobals(ctx context.Context, pending []string, conn *pgx.Conn, fsys fs.
for _, path := range pending {
filename := filepath.Base(path)
fmt.Fprintf(os.Stderr, "Seeding globals from %s...\n", filename)
if globals, err := NewMigrationFromFile(path, fsys); err != nil {
globals, err := NewMigrationFromFile(path, fsys)
if err != nil {
return err
} else if err := globals.ExecBatch(ctx, conn); err != nil {
}
// Skip inserting to migration history
globals.Version = ""
if err := globals.ExecBatch(ctx, conn); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/migration/seed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func TestSeedData(t *testing.T) {
})
}

//go:embed testdata/globals.sql
//go:embed testdata/1_globals.sql
var testGlobals string

func TestSeedGlobals(t *testing.T) {
pending := []string{"testdata/globals.sql"}
pending := []string{"testdata/1_globals.sql"}

t.Run("seeds from file", func(t *testing.T) {
// Setup mock postgres
Expand Down
File renamed without changes.

0 comments on commit cd94f35

Please sign in to comment.