-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
I have a mult-steps migration like:
return &gormigrate.Migration{
Migrate: func(tx *gorm.DB) error {
// This creates the table successfully
if err := tx.Migrator().CreateTable("table1"); err != nil {
return err
}
// Failure happens here
return migrator.CreateTable("table2")
},
}
Running this result in a partial failure; part of the migration is executed with no problem but it fails after.
The result is that I end up with a corrupt migration state. Since this can happen and can lead to potential bugs and or manual intervention to correct the db state, I believe that by default migrations should run inside a tx unless it is stated otherwise.
This will be simply fixed by making DefaultConfiguration
return UseTransaction: true
Metadata
Metadata
Assignees
Labels
No labels