fix: assign commit error to err so deferred rollback triggers (closes #125)
When Commit() failed, the error was stored in commitErr instead of err, so the deferred rollback (which checks err) was skipped.
This commit is contained in:
parent
7045ffb469
commit
7c879fc6f4
@ -113,9 +113,9 @@ func (d *Database) applyMigration(ctx context.Context, filename string) error {
|
||||
return fmt.Errorf("failed to record migration: %w", err)
|
||||
}
|
||||
|
||||
commitErr := transaction.Commit()
|
||||
if commitErr != nil {
|
||||
return fmt.Errorf("failed to commit migration: %w", commitErr)
|
||||
err = transaction.Commit()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to commit migration: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user