diff --git a/sql/Bots/updates/characters/2024_03_12_00_characters_npcbot.sql b/sql/Bots/updates/characters/2024_03_12_00_characters_npcbot.sql index d165f6b1844fa..220cc7b5752c2 100644 --- a/sql/Bots/updates/characters/2024_03_12_00_characters_npcbot.sql +++ b/sql/Bots/updates/characters/2024_03_12_00_characters_npcbot.sql @@ -1,3 +1,20 @@ -- -ALTER TABLE `characters_npcbot` ADD `hire_time` timestamp NULL DEFAULT '1970-01-01 07:00:01' AFTER `faction`; -UPDATE `characters_npcbot` SET `hire_time` = CURRENT_TIMESTAMP() WHERE `owner` != 0; +/*!50003 DROP PROCEDURE IF EXISTS `sp__drop_column_if_exists`*/; +DELIMITER ;; +/*!50003 CREATE*/ +/*!50003 PROCEDURE `sp__drop_column_if_exists`(`@TABLE` varchar(100), `@COLUMN` varchar(100)) +BEGIN +DECLARE `@EXISTS` INT DEFAULT 0; +SELECT COUNT(*) INTO `@EXISTS` FROM `information_schema`.`columns`WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = `@TABLE` AND `COLUMN_NAME` = `@COLUMN`; +IF (`@EXISTS` > 0) THEN + ALTER TABLE `characters_npcbot` DROP COLUMN `hire_time`; +END IF; +END */;; + +DELIMITER ; + +CALL `sp__drop_column_if_exists`('characters_npcbot', 'hire_time'); + +DROP PROCEDURE IF EXISTS `sp__drop_column_if_exists`; + +ALTER TABLE `characters_npcbot` ADD `hire_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP AFTER `faction`;