mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Merge branch 'realm-indexed-online-id' into realm-importer
This commit is contained in:
@ -28,7 +28,12 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
public readonly string Filename;
|
||||
|
||||
private const int schema_version = 6;
|
||||
/// <summary>
|
||||
/// Version history:
|
||||
/// 6 First tracked version (~20211018)
|
||||
/// 7 Changed OnlineID fields to non-nullable to add indexing support (20211018)
|
||||
/// </summary>
|
||||
private const int schema_version = 7;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking context creation during blocking periods.
|
||||
@ -143,6 +148,31 @@ namespace osu.Game.Database
|
||||
|
||||
private void onMigration(Migration migration, ulong lastSchemaVersion)
|
||||
{
|
||||
if (lastSchemaVersion < 7)
|
||||
{
|
||||
convertOnlineIDs<RealmBeatmap>();
|
||||
convertOnlineIDs<RealmBeatmapSet>();
|
||||
convertOnlineIDs<RealmRuleset>();
|
||||
|
||||
void convertOnlineIDs<T>() where T : RealmObject
|
||||
{
|
||||
var className = typeof(T).Name.Replace(@"Realm", string.Empty);
|
||||
|
||||
var oldItems = migration.OldRealm.DynamicApi.All(className);
|
||||
var newItems = migration.NewRealm.DynamicApi.All(className);
|
||||
|
||||
int itemCount = newItems.Count();
|
||||
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
var oldItem = oldItems.ElementAt(i);
|
||||
var newItem = newItems.ElementAt(i);
|
||||
|
||||
long? nullableOnlineID = oldItem?.OnlineID;
|
||||
newItem.OnlineID = (int)(nullableOnlineID ?? -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user