Skip to content

Commit

Permalink
use db.Transaction helper for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Oct 9, 2023
1 parent 219aa74 commit 422a4b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions db/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (db *DB) Migrate(ctx MigrationContext) error {

func construct(ctx MigrationContext, id string, f func(*gorm.DB, MigrationContext) error) *gormigrate.Migration {
return constructNoTx(ctx, id, func(db *gorm.DB, ctx MigrationContext) error {
tx := db.Begin()
defer tx.Commit()
return f(tx, ctx)
return db.Transaction(func(tx *gorm.DB) error {
return f(tx, ctx)
})
})
}

Expand Down

0 comments on commit 422a4b8

Please sign in to comment.