Skip to content

Commit 422a4b8

Browse files
committed
use db.Transaction helper for migrations
1 parent 219aa74 commit 422a4b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

db/migrations.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ func (db *DB) Migrate(ctx MigrationContext) error {
7474

7575
func construct(ctx MigrationContext, id string, f func(*gorm.DB, MigrationContext) error) *gormigrate.Migration {
7676
return constructNoTx(ctx, id, func(db *gorm.DB, ctx MigrationContext) error {
77-
tx := db.Begin()
78-
defer tx.Commit()
79-
return f(tx, ctx)
77+
return db.Transaction(func(tx *gorm.DB) error {
78+
return f(tx, ctx)
79+
})
8080
})
8181
}
8282

0 commit comments

Comments
 (0)