mirror of
https://github.com/grafana/grafana.git
synced 2025-01-13 09:32:12 -06:00
log skipped, performed and duration for migrations (#31722)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
parent
ab2f405205
commit
c899bf3592
@ -79,11 +79,15 @@ func (mg *Migrator) Start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
migrationsPerformed := 0
|
||||
migrationsSkipped := 0
|
||||
start := time.Now()
|
||||
for _, m := range mg.migrations {
|
||||
m := m
|
||||
_, exists := logMap[m.Id()]
|
||||
if exists {
|
||||
mg.Logger.Debug("Skipping migration: Already executed", "id", m.Id())
|
||||
migrationsSkipped++
|
||||
continue
|
||||
}
|
||||
|
||||
@ -107,6 +111,9 @@ func (mg *Migrator) Start() error {
|
||||
}
|
||||
record.Success = true
|
||||
_, err = sess.Insert(&record)
|
||||
if err == nil {
|
||||
migrationsPerformed++
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
@ -114,6 +121,8 @@ func (mg *Migrator) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
mg.Logger.Info("migrations completed", "performed", migrationsPerformed, "skipped", migrationsSkipped, "duration", time.Since(start))
|
||||
|
||||
// Make sure migrations are synced
|
||||
return mg.x.Sync2()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user