Skip to content

Commit 7ee85fb

Browse files
alnrory-bot
authored andcommitted
fix: remove WithDumpMigrations option to MigrationBox
GitOrigin-RevId: ec8bf6fb2d78337c71a158ba2f65dfe2e2d612f6
1 parent 7bb24c5 commit 7ee85fb

3 files changed

Lines changed: 12 additions & 21 deletions

File tree

oryx/popx/migration_box.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type (
3030
migrationsUp Migrations
3131
migrationsDown Migrations
3232
perMigrationTimeout time.Duration
33-
dumpMigrations bool
3433
l *logrusx.Logger
3534
migrationContent MigrationContent
3635
}
@@ -77,12 +76,6 @@ func WithPerMigrationTimeout(timeout time.Duration) MigrationBoxOption {
7776
}
7877
}
7978

80-
func WithDumpMigrations() MigrationBoxOption {
81-
return func(m *MigrationBox) {
82-
m.dumpMigrations = true
83-
}
84-
}
85-
8679
// WithTestdata adds testdata to the migration box.
8780
func WithTestdata(t *testing.T, testdata fs.FS) MigrationBoxOption {
8881
testdataPattern := regexp.MustCompile(`^(\d+)_testdata(|\.[a-zA-Z0-9]+).sql$`)

oryx/popx/migrator.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func (mb *MigrationBox) Status(ctx context.Context) (MigrationStatuses, error) {
471471
func (mb *MigrationBox) DumpMigrationSchema(ctx context.Context) error {
472472
c := mb.c.WithContext(ctx)
473473
schema := "schema.sql"
474-
f, err := os.Create(schema) //#nosec:G304) //#nosec:G304
474+
f, err := os.Create(schema) //#nosec:G304
475475
if err != nil {
476476
return errors.WithStack(err)
477477
}
@@ -485,15 +485,6 @@ func (mb *MigrationBox) DumpMigrationSchema(ctx context.Context) error {
485485

486486
func (mb *MigrationBox) exec(ctx context.Context, fn func() error) error {
487487
now := time.Now()
488-
defer func() {
489-
if !mb.dumpMigrations {
490-
return
491-
}
492-
err := mb.DumpMigrationSchema(ctx)
493-
if err != nil {
494-
mb.l.WithError(err).Error("Migrator: unable to dump schema")
495-
}
496-
}()
497488
defer mb.printTimer(now)
498489

499490
err := mb.CreateSchemaMigrations(ctx)

persistence/sql/migratest/migration_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
127127
c, l,
128128
popx.WithGoMigrations(gomigrations.All),
129129
popx.WithTestdata(t, os.DirFS("./testdata")),
130-
popx.WithDumpMigrations(),
131130
)
132131
require.NoError(t, err)
133-
require.NoError(t, tm.Up(ctx))
134-
// t.Skip() // uncomment to get the current state of the database after the migrations have run
132+
133+
err = tm.Up(ctx) // for easy breakpointing
134+
// _ = tm.DumpMigrationSchema(ctx) // uncomment to get the current state of the database after migrations have run
135+
if !assert.NoError(t, err) {
136+
assert.NoError(t, tm.DumpMigrationSchema(ctx))
137+
t.FailNow()
138+
}
135139

136140
t.Run("suite=fixtures", func(t *testing.T) {
137141
t.Cleanup(func() {
@@ -477,5 +481,8 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
477481
})
478482

479483
err = tm.Down(ctx, -1) // for easy breakpointing
480-
require.NoError(t, err)
484+
if !assert.NoError(t, err) {
485+
assert.NoError(t, tm.DumpMigrationSchema(ctx))
486+
t.FailNow()
487+
}
481488
}

0 commit comments

Comments
 (0)