diff options
| author | offl <offl@users.noreply.github.com> | 2020-06-26 20:14:45 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-19 00:06:09 +0100 |
| commit | 09ee27d03df1fa8fe86fbc9489cc823180160b92 (patch) | |
| tree | 88b89aee8450c0b92717f11f441b8cd6d7e7ebd9 /sql | |
| parent | 342754baa378c0c9f4c1e53951485619e9b4cc4d (diff) | |
DB/Creature: Remove model from creature table if not needed
Closes #24822
(cherry picked from commit 2211610ff75dfb712bb49fc41ebcc4e7d92394ae)
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/updates/world/master/2022_01_18_07_world_2020_06_26_06_world.sql | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sql/updates/world/master/2022_01_18_07_world_2020_06_26_06_world.sql b/sql/updates/world/master/2022_01_18_07_world_2020_06_26_06_world.sql new file mode 100644 index 00000000000..9ad0b083530 --- /dev/null +++ b/sql/updates/world/master/2022_01_18_07_world_2020_06_26_06_world.sql @@ -0,0 +1,25 @@ +-- +-- set creature.modelid to 0 if creature only has a single model defined in creature_template_model and that model matches value in creature table +CREATE TEMPORARY TABLE creature_guids_with_unique_model SELECT + c.guid +FROM + `creature` c + INNER JOIN ( + SELECT + ctm.CreatureDisplayID AS CreatureDisplayID, + ctm.CreatureID AS CreatureID + FROM + creature_template_model ctm + GROUP BY + ctm.CreatureID + HAVING + COUNT(ctm.CreatureDisplayID) = 1 + ) uniq_models ON c.id = uniq_models.CreatureID + AND c.modelid = uniq_models.CreatureDisplayID; + +UPDATE `creature` SET `modelid`=0 WHERE `guid` IN (SELECT * FROM creature_guids_with_unique_model); + +-- UPDATE `creature` a LEFT JOIN `creature_template` b ON a.`id` = b.`entry` SET `modelid` = 0 WHERE a.`id` IN (SELECT b.`entry` FROM `creature_template` WHERE b.`modelid1` != 0 AND b.`modelid2` = 0 AND b.`modelid3` = 0 AND b.`modelid4` = 0) AND a.`modelid` = b.`modelid1`; +-- UPDATE `creature` a LEFT JOIN `creature_template` b ON a.`id` = b.`entry` SET `modelid` = 0 WHERE a.`id` IN (SELECT b.`entry` FROM `creature_template` WHERE b.`modelid1` = 0 AND b.`modelid2` != 0 AND b.`modelid3` = 0 AND b.`modelid4` = 0) AND a.`modelid` = b.`modelid2`; +-- UPDATE `creature` a LEFT JOIN `creature_template` b ON a.`id` = b.`entry` SET `modelid` = 0 WHERE a.`id` IN (SELECT b.`entry` FROM `creature_template` WHERE b.`modelid1` != 0 AND b.`modelid2` != 0 AND b.`modelid3` != 0 AND b.`modelid4` != 0) AND (a.`modelid` = b.`modelid1` OR a.`modelid` = b.`modelid2` OR a.`modelid` = b.`modelid3` OR a.`modelid` = b.`modelid4`); +UPDATE `creature` SET `modelid` = 0 WHERE `id`=1505; |
