mirror of https://github.com/ppy/osu
Add basic realm migration support
This commit is contained in:
parent
5d7ab4a7f1
commit
ae76eca564
|
@ -43,6 +43,15 @@ public RealmContextFactory(Storage storage, Scheduler scheduler)
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
recreateThreadContexts();
|
recreateThreadContexts();
|
||||||
|
|
||||||
|
using (CreateContext())
|
||||||
|
{
|
||||||
|
// ensure our schema is up-to-date and migrated.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onMigration(Migration migration, ulong oldschemaversion)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly GlobalStatistic<int> reads = GlobalStatistics.Get<int>("Realm", "Get (Read)");
|
private static readonly GlobalStatistic<int> reads = GlobalStatistics.Get<int>("Realm", "Get (Read)");
|
||||||
|
@ -158,7 +167,11 @@ private void recreateThreadContexts()
|
||||||
protected virtual Realm CreateContext()
|
protected virtual Realm CreateContext()
|
||||||
{
|
{
|
||||||
contexts.Value++;
|
contexts.Value++;
|
||||||
return Realm.GetInstance(new RealmConfiguration(storage.GetFullPath($"{database_name}.realm", true)));
|
return Realm.GetInstance(new RealmConfiguration(storage.GetFullPath($"{database_name}.realm", true))
|
||||||
|
{
|
||||||
|
SchemaVersion = 2,
|
||||||
|
MigrationCallback = onMigration
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetDatabase()
|
public void ResetDatabase()
|
||||||
|
|
Loading…
Reference in New Issue