Skip to content

Commit

Permalink
Do level removes in separate transaction from event removal (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden authored Nov 29, 2023
2 parents e5584c9 + 4bdac54 commit 594fc8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Refresh.GameServer/Database/GameDatabaseContext.Levels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public void DeleteLevel(GameLevel level)

#endregion

});

//do in separate transaction in a vain attempt to fix Weirdness with favourite level relations having missing levels
this._realm.Write(() =>
{
this._realm.Remove(level);
});
}
Expand Down
5 changes: 4 additions & 1 deletion Refresh.GameServer/Database/GameDatabaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected GameDatabaseProvider(IDateTimeProvider time)
this._time = time;
}

protected override ulong SchemaVersion => 100;
protected override ulong SchemaVersion => 101;

protected override string Filename => "refreshGameServer.realm";

Expand Down Expand Up @@ -165,6 +165,9 @@ protected override void Migrate(Migration migration, ulong oldVersion)

// In version 100, we started enforcing lowercase email addresses
if (oldVersion < 100) newUser.EmailAddress = oldUser.EmailAddress?.ToLowerInvariant();

// Version was bumped here to delete invalid favourite level relations
if (oldVersion < 101) migration.NewRealm.RemoveRange(newUser.FavouriteLevelRelations.Where(r => r.Level == null));
}

IQueryable<dynamic>? oldLevels = migration.OldRealm.DynamicApi.All("GameLevel");
Expand Down

0 comments on commit 594fc8b

Please sign in to comment.