diff --git a/Refresh.GameServer/Database/GameDatabaseContext.Levels.cs b/Refresh.GameServer/Database/GameDatabaseContext.Levels.cs index dc6a9961..939eb6c6 100644 --- a/Refresh.GameServer/Database/GameDatabaseContext.Levels.cs +++ b/Refresh.GameServer/Database/GameDatabaseContext.Levels.cs @@ -154,6 +154,7 @@ public void DeleteLevel(GameLevel level) this.RateLevelRelations.RemoveRange(r => r.Level == level); this.UniquePlayLevelRelations.RemoveRange(r => r.Level == level); this.TagLevelRelations.RemoveRange(r => r.Level == level); + this.GameReviews.RemoveRange(r => r.Level == level); IQueryable scores = this.GameSubmittedScores.Where(r => r.Level == level); diff --git a/Refresh.GameServer/Database/GameDatabaseProvider.cs b/Refresh.GameServer/Database/GameDatabaseProvider.cs index 336023c2..b32859af 100644 --- a/Refresh.GameServer/Database/GameDatabaseProvider.cs +++ b/Refresh.GameServer/Database/GameDatabaseProvider.cs @@ -33,7 +33,7 @@ protected GameDatabaseProvider(IDateTimeProvider time) this._time = time; } - protected override ulong SchemaVersion => 138; + protected override ulong SchemaVersion => 139; protected override string Filename => "refreshGameServer.realm"; @@ -557,5 +557,8 @@ protected override void Migrate(Migration migration, ulong oldVersion) newPlayLevelRelation.Count = 1; } } + + // We weren't deleting reviews when a level was deleted. Version 139 fixes this. + if (oldVersion < 139) migration.NewRealm.RemoveRange(migration.NewRealm.All().Where(r => r.Level == null)); } } \ No newline at end of file