Add child relation deletion by parent query: Introduced a new SQL query to delete child relations where the character is either a father or mother. Updated relevant workers to execute this query before deleting child relations, ensuring proper cleanup of relationships during character deletion.

This commit is contained in:
Torsten Schulz (local)
2026-02-04 14:46:57 +01:00
parent 2293c1204b
commit d94fa791b3
8 changed files with 34 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ use crate::worker::sql::{
QUERY_DELETE_DIRECTOR,
QUERY_DELETE_RELATIONSHIP,
QUERY_DELETE_CHILD_RELATION,
QUERY_DELETE_CHILD_RELATION_BY_PARENT,
QUERY_INSERT_NOTIFICATION,
QUERY_MARK_CHARACTER_DECEASED,
};
@@ -426,7 +427,9 @@ impl CharacterCreationWorker {
}
}
// 3) Child-Relations löschen und Eltern benachrichtigen
// 3) Child-Relations löschen (als Elter zuerst, dann als Kind) und Eltern benachrichtigen
conn.prepare("delete_child_relation_by_parent", QUERY_DELETE_CHILD_RELATION_BY_PARENT)?;
conn.execute("delete_child_relation_by_parent", &[&character_id])?;
conn.prepare("delete_child_relation", QUERY_DELETE_CHILD_RELATION)?;
let child_result = conn.execute("delete_child_relation", &[&character_id])?;
for row in child_result {