better logging during critical migration error (#8576)

pull/8836/head
Matt Hook 2 years ago committed by GitHub
parent 3c26aa8f34
commit 1b470845b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -48,13 +48,16 @@ func (store *Store) MigrateData() error {
err = store.FailSafeMigrate(migrator, version) err = store.FailSafeMigrate(migrator, version)
if err != nil { if err != nil {
err = errors.Wrap(err, "failed to migrate database")
log.Warn().Msg("migration failed, restoring database to previous version")
err = store.restoreWithOptions(&BackupOptions{BackupPath: backupPath}) err = store.restoreWithOptions(&BackupOptions{BackupPath: backupPath})
if err != nil { if err != nil {
return errors.Wrap(err, "failed to restore database") return errors.Wrap(err, "failed to restore database")
} }
log.Info().Msg("database restored to previous version") log.Info().Msg("database restored to previous version")
return errors.Wrap(err, "failed to migrate database") return err
} }
return nil return nil

Loading…
Cancel
Save