Cascade delete mini game ranking entries
A character which has participated in a mini game with enabled ranking statistics could not be deleted. The database rejected it with Npgsql.PostgresException 23503: update or delete on table "Character" violates foreign key constraint "FK_MiniGameRankingEntry_Character_CharacterId" MiniGameRankingEntry is a member of neither the character nor the mini game definition aggregate, so the model generator doesn't emit a delete behavior for its references. The entity was registered without any additional configuration, so Entity Framework fell back to no action for these optional relationships, which the database translates into a restricting foreign key. Both references are now configured with a cascading delete, matching the behavior of the other references to a character. With that, all seven relationships pointing to Character delete their dependents. This affects both deletion paths: the one of the player (DeleteCharacterAction) and the one of an administrator, who can remove a character from the account in the admin panel. The cascade on the mini game definition is deliberate and part of the same defect: deleting a definition in the admin panel ran into the very same restriction. It does mean that the ranking history of a mini game is dropped together with its definition. Reported in issue 796. (cherry picked from commit a391bdedbbd3a36ccb37124125bd7ede4f851dca)
This commit is contained in:
@@ -44,7 +44,7 @@ public class EntityDataContext : ExtendedTypeContext
|
||||
modelBuilder.Entity<Model.AttributeDefinition>();
|
||||
modelBuilder.Entity<ConnectServerDefinition>();
|
||||
modelBuilder.Entity<ChatServerDefinition>();
|
||||
modelBuilder.Entity<MiniGameRankingEntry>();
|
||||
modelBuilder.Entity<MiniGameRankingEntry>().Apply();
|
||||
modelBuilder.Entity<GameServerDefinition>(entity =>
|
||||
{
|
||||
entity.Property(e => e.PvpEnabled).HasDefaultValue(true);
|
||||
|
||||
Reference in New Issue
Block a user