From 9ac2bcda715bb6d08baf956522c3e89f75ec6f15 Mon Sep 17 00:00:00 2001 From: trickerer Date: Wed, 13 Mar 2024 11:55:41 +0700 Subject: [PATCH] NPCBots: Fix `hire_time` default value 2 --- .../2024_03_12_00_characters_npcbot.sql | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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`;