3
0

Run migration in a transaction

Big performance gains, since indexes are defered to
the end.
This commit is contained in:
Tomaž Jerman
2020-03-01 20:56:45 +01:00
parent e30edaae4f
commit 52e4e6c176

View File

@@ -185,6 +185,7 @@ func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error {
db := repository.DB(ctx)
repoRecord := repository.Record(ctx, db)
return db.Transaction(func() (err error) {
for len(m.Leafs) > 0 {
var wg sync.WaitGroup
@@ -224,7 +225,8 @@ func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error {
m.Leafs = nl
}
return nil
return nil
})
}
// migrates provided users