From 67d805f700b8f9272f8f8283bd34d708c7b35e2a Mon Sep 17 00:00:00 2001 From: blinkysc <37940565+blinkysc@users.noreply.github.com> Date: Thu, 27 Feb 2025 00:34:26 -0600 Subject: [PATCH] Cleanup Database More (#1032) * Resolve conflicts * format --- src/RandomPlayerbotFactory.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 37bc3eff..4857e030 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -455,7 +455,14 @@ void RandomPlayerbotFactory::CreateRandomBots() // Delete all characters from bot accounts CharacterDatabase.Execute("DELETE FROM characters WHERE account IN (SELECT id FROM acore_auth.account WHERE username LIKE '{}%%')", sPlayerbotAIConfig->randomBotAccountPrefix.c_str()); - + + // Clean up orphaned entries in playerbots_guild_tasks + PlayerbotsDatabase.Execute("DELETE FROM playerbots_guild_tasks WHERE owner NOT IN (SELECT guid FROM acore_characters.characters)"); + + // Clean up orphaned entries in playerbots_db_store + PlayerbotsDatabase.Execute("DELETE FROM playerbots_db_store WHERE guid NOT IN (SELECT guid FROM acore_characters.characters WHERE account IN (SELECT id FROM acore_auth.account WHERE username NOT LIKE '{}%%'))", + sPlayerbotAIConfig->randomBotAccountPrefix.c_str()); + // Clean up orphaned records in character-related tables CharacterDatabase.Execute("DELETE FROM arena_team_member WHERE guid NOT IN (SELECT guid FROM characters)"); CharacterDatabase.Execute("DELETE FROM arena_team WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team_member)");