From 1b470845b8258f2e4b02ff77a55d6a49f86bbd2e Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Fri, 21 Apr 2023 09:30:12 +1200 Subject: [PATCH] better logging during critical migration error (#8576) --- api/datastore/migrate_data.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/datastore/migrate_data.go b/api/datastore/migrate_data.go index 15cfa4638..8231ef006 100644 --- a/api/datastore/migrate_data.go +++ b/api/datastore/migrate_data.go @@ -48,13 +48,16 @@ func (store *Store) MigrateData() error { err = store.FailSafeMigrate(migrator, version) 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}) if err != nil { return errors.Wrap(err, "failed to restore database") } log.Info().Msg("database restored to previous version") - return errors.Wrap(err, "failed to migrate database") + return err } return nil