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

@@ -544,6 +544,11 @@ WITH deleted AS (
SELECT cf.user_id AS father_user_id, cm.user_id AS mother_user_id FROM deleted d JOIN falukant_data.character cf ON cf.id = d.father_character_id JOIN falukant_data.character cm ON cm.id = d.mother_character_id;
"#;
/// Entfernt alle child_relation-Zeilen, in denen der Charakter Vater oder Mutter ist (nötig vor Charakter-Löschung).
pub const QUERY_DELETE_CHILD_RELATION_BY_PARENT: &str = r#"
DELETE FROM falukant_data.child_relation WHERE father_character_id = $1 OR mother_character_id = $1;
"#;
pub const QUERY_DELETE_CHARACTER: &str = r#"
DELETE FROM falukant_data.character WHERE id = $1;
"#;