Skip to content

Commit

Permalink
fix(migrate): change rollback to match migrate behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Mar 25, 2022
1 parent 4159437 commit df5af9c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,16 @@ func (m *Migrator) Rollback(ctx context.Context, opts ...MigrationOption) (*Migr
for i := len(lastGroup.Migrations) - 1; i >= 0; i-- {
migration := &lastGroup.Migrations[i]

// Always mark migration as unapplied to match migrate behavior.
if err := m.MarkUnapplied(ctx, migration); err != nil {
return nil, err
}

if !cfg.nop && migration.Down != nil {
if err := migration.Down(ctx, m.db); err != nil {
return nil, err
}
}

if err := m.MarkUnapplied(ctx, migration); err != nil {
return nil, err
}
}

return lastGroup, nil
Expand Down

0 comments on commit df5af9c

Please sign in to comment.