Merge pull request #15189 from peppy/fix-migration-failure-old-version

Fix realm migration potentially failing from older releases
This commit is contained in:
Dan Balasescu 2021-10-19 15:19:50 +09:00 committed by GitHub
commit f159710aae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -137,6 +137,11 @@ void convertOnlineIDs<T>() where T : RealmObject
{
var className = typeof(T).Name.Replace(@"Realm", string.Empty);
// version was not bumped when the beatmap/ruleset models were added
// therefore we must manually check for their presence to avoid throwing on the `DynamicApi` calls.
if (!migration.OldRealm.Schema.TryFindObjectSchema(className, out _))
return;
var oldItems = migration.OldRealm.DynamicApi.All(className);
var newItems = migration.NewRealm.DynamicApi.All(className);