Skip to content

Commit

Permalink
Remove reviews when deleting levels
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Aug 3, 2024
1 parent b01ce09 commit b09bdda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Refresh.GameServer/Database/GameDatabaseContext.Levels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameSubmittedScore> scores = this.GameSubmittedScores.Where(r => r.Level == 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 @@ -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";

Expand Down Expand Up @@ -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<GameReview>().Where(r => r.Level == null));
}
}

0 comments on commit b09bdda

Please sign in to comment.