Simplify migration to not rely on old/dynamic schema

This commit is contained in:
Dean Herbert 2023-02-08 14:24:06 +09:00
parent 5c113ddb03
commit c50ea89bc9
1 changed files with 4 additions and 10 deletions

View File

@ -869,17 +869,11 @@ void convertOnlineIDs<T>() where T : RealmObject
break;
case 26:
// Add ScoreInfo.BeatmapHash property to ensure the score corresponds to the version of beatmap it should
// See: https://github.com/ppy/osu/issues/22062
string scoreInfoName = getMappedOrOriginalName(typeof(ScoreInfo));
// Add ScoreInfo.BeatmapHash property to ensure scores correspond to the correct version of beatmap.
var scores = migration.NewRealm.All<ScoreInfo>();
var oldScoreInfos = migration.OldRealm.DynamicApi.All(scoreInfoName);
var newScoreInfos = migration.NewRealm.All<ScoreInfo>();
for (int i = 0; i < newScoreInfos.Count(); i++)
{
newScoreInfos.ElementAt(i).BeatmapHash = oldScoreInfos.ElementAt(i).BeatmapInfo.Hash;
}
foreach (var score in scores)
score.BeatmapHash = score.BeatmapInfo.Hash;
break;
}