Add fallback logic for the case where previous database can't be migrated

This commit is contained in:
Dean Herbert
2017-10-19 21:37:09 +09:00
parent 7ce6167220
commit 8aea6068ba
2 changed files with 22 additions and 9 deletions

View File

@ -221,19 +221,25 @@ namespace osu.Game.Database
Database.ExecuteSqlCommand(
"INSERT INTO BeatmapInfo SELECT ID, AudioLeadIn, BaseDifficultyID, BeatDivisor, BeatmapSetInfoID, Countdown, DistanceSpacing, GridSize, Hash, Hidden, LetterboxInBreaks, MD5Hash, NULLIF(BeatmapMetadataID, 0), OnlineBeatmapID, Path, RulesetID, SpecialStyle, StackLeniency, StarDifficulty, StoredBookmarks, TimelineZoom, Version, WidescreenStoryboard FROM BeatmapInfo_Old");
Database.ExecuteSqlCommand("DROP TABLE BeatmapInfo_Old");
throw new Exception();
}
catch
{
// if anything went wrong during migration just nuke the database.
Database.EnsureDeleted();
throw new MigrationFailedException();
}
}
catch (MigrationFailedException e)
{
throw;
}
catch
{
}
}
}
}
public class MigrationFailedException : Exception
{
}
}