use db.Transaction helper for migrations

This commit is contained in:
sentriz
2023-10-09 23:31:51 +01:00
parent 219aa747c9
commit 422a4b88d7

View File

@@ -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)
})
})
}