Fix multiple issues causing database reset to fail

This commit is contained in:
Dean Herbert
2018-06-04 02:07:02 +09:00
parent 68910745d8
commit 3a823d6c25
3 changed files with 44 additions and 18 deletions

View File

@ -211,15 +211,17 @@ namespace osu.Game
using (var db = contextFactory.GetForWrite(false))
db.Context.Migrate();
}
catch (MigrationFailedException e)
catch (Exception e)
{
Logger.Error(e.InnerException ?? e, "Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database);
// if we failed, let's delete the database and start fresh.
// todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this.
contextFactory.ResetDatabase();
Logger.Log("Database purged successfully.", LoggingTarget.Database, LogLevel.Important);
// only run once more, then hard bail.
using (var db = contextFactory.GetForWrite(false))
db.Context.Migrate();
}