mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 00:58:33 +00:00
check if already exist before apply (#1254)
This commit is contained in:
@@ -1,9 +1,25 @@
|
|||||||
-- ##########################################################
|
-- ##########################################################
|
||||||
-- # Playerbots RandomBots Performance Update
|
-- # Playerbots RandomBots Performance Update
|
||||||
-- # Add missing index to reduce Deadlocks
|
-- # Add missing index to reduce Deadlocks
|
||||||
-- # Author: Raz0r1337 aka St0ny
|
-- # Author: Raz0r1337 aka St0ny
|
||||||
-- # Date: 2025-04-26
|
-- # Date: 2025-04-26
|
||||||
-- ##########################################################
|
-- ##########################################################
|
||||||
|
|
||||||
ALTER TABLE `playerbots_random_bots`
|
-- Check if the index already exists
|
||||||
ADD INDEX `idx_owner_bot_event` (`owner`, `bot`, `event`);
|
SET @index_exists := (
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM INFORMATION_SCHEMA.STATISTICS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'playerbots_random_bots'
|
||||||
|
AND INDEX_NAME = 'idx_owner_bot_event'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Conditionally create the index only if it doesn't exist
|
||||||
|
SET @ddl := IF(@index_exists = 0,
|
||||||
|
'ALTER TABLE `playerbots_random_bots` ADD INDEX `idx_owner_bot_event` (`owner`, `bot`, `event`);',
|
||||||
|
'SELECT "Index idx_owner_bot_event already exists.";'
|
||||||
|
);
|
||||||
|
|
||||||
|
PREPARE stmt FROM @ddl;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|||||||
Reference in New Issue
Block a user