Add migration of existing settings

This commit is contained in:
Dean Herbert 2021-09-15 15:22:16 +09:00
parent ac377a2e3c
commit 2bcb3fd304

View File

@ -469,6 +469,25 @@ namespace osu.Game
db.Context.RemoveRange(existingBindings);
var existingSettings = db.Context.DatabasedSetting;
// only migrate data if the realm database is empty.
if (!usage.Realm.All<RealmSetting>().Any())
{
foreach (var dkb in existingSettings)
{
usage.Realm.Add(new RealmSetting
{
ValueString = dkb.StringValue,
Key = dkb.Key,
RulesetID = dkb.RulesetID,
Variant = dkb.Variant
});
}
}
db.Context.RemoveRange(existingSettings);
usage.Commit();
}
}