Skip to content

Commit

Permalink
Faction Quartermaster Satchel updated to proper requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Necrovoice committed Jul 21, 2022
1 parent 0cebe51 commit f94176c
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions World/Updates/Rel22/Rel22_03_004_Item_faction_Req.sql
@@ -0,0 +1,115 @@
-- ----------------------------------------------------------------
-- This is an attempt to create a full transactional MaNGOS update
-- Now compatible with newer MySql Databases (v1.5)
-- ----------------------------------------------------------------
DROP PROCEDURE IF EXISTS `update_mangos`;

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `update_mangos`()
BEGIN
DECLARE bRollback BOOL DEFAULT FALSE ;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `bRollback` = TRUE;

-- Current Values (TODO - must be a better way to do this)
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurStructure := (SELECT `structure` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurContent := (SELECT `content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);

-- Expected Values
SET @cOldVersion = '22';
SET @cOldStructure = '03';
SET @cOldContent = '003';

-- New Values
SET @cNewVersion = '22';
SET @cNewStructure = '03';
SET @cNewContent = '004';
-- DESCRIPTION IS 30 Characters MAX
SET @cNewDescription = 'Item faction Req';

-- COMMENT is 150 Characters MAX
SET @cNewComment = 'Item faction Req';

-- Evaluate all settings
SET @cCurResult := (SELECT `description` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cOldResult := (SELECT `description` FROM `db_version` WHERE `version`=@cOldVersion AND `structure`=@cOldStructure AND `content`=@cOldContent);
SET @cNewResult := (SELECT `description` FROM `db_version` WHERE `version`=@cNewVersion AND `structure`=@cNewStructure AND `content`=@cNewContent);

IF (@cCurResult = @cOldResult) THEN -- Does the current version match the expected version
-- APPLY UPDATE
START TRANSACTION;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- -- PLACE UPDATE SQL BELOW -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

-- Faction Quartermaster Satchel updated to proper requirements.
-- Alliance
UPDATE `item_template` SET `RequiredReputationFaction` = 1134, `RequiredReputationRank` = 6 WHERE `entry` = 67532;
UPDATE `item_template` SET `RequiredReputationFaction` = 72, `RequiredReputationRank` = 6 WHERE `entry` = 67531;
UPDATE `item_template` SET `RequiredReputationFaction` = 47, `RequiredReputationRank` = 6 WHERE `entry` = 67528;
UPDATE `item_template` SET `RequiredReputationFaction` = 54, `RequiredReputationRank` = 6 WHERE `entry` = 67530;
UPDATE `item_template` SET `RequiredReputationFaction` = 69, `RequiredReputationRank` = 6 WHERE `entry` = 67526;
UPDATE `item_template` SET `RequiredReputationFaction` = 930, `RequiredReputationRank` = 6 WHERE `entry` = 67527;
-- Horde
UPDATE `item_template` SET `RequiredReputationFaction` = 911, `RequiredReputationRank` = 6 WHERE `entry` = 67535;
UPDATE `item_template` SET `RequiredReputationFaction` = 68, `RequiredReputationRank` = 6 WHERE `entry` = 67529;
UPDATE `item_template` SET `RequiredReputationFaction` = 81, `RequiredReputationRank` = 6 WHERE `entry` = 67534;
UPDATE `item_template` SET `RequiredReputationFaction` = 78, `RequiredReputationRank` = 6 WHERE `entry` = 67533;
UPDATE `item_template` SET `RequiredReputationFaction` = 530, `RequiredReputationRank` = 6 WHERE `entry` = 67536;
UPDATE `item_template` SET `RequiredReputationFaction` = 1133, `RequiredReputationRank` = 6 WHERE `entry` = 67525;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- -- PLACE UPDATE SQL ABOVE -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

-- If we get here ok, commit the changes
IF bRollback = TRUE THEN
ROLLBACK;
SHOW ERRORS;
SELECT '* UPDATE FAILED *' AS `===== Status =====`,@cCurResult AS `===== DB is on Version: =====`;
ELSE
COMMIT;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- UPDATE THE DB VERSION
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
INSERT INTO `db_version` VALUES (@cNewVersion, @cNewStructure, @cNewContent, @cNewDescription, @cNewComment);
SET @cNewResult := (SELECT `description` FROM `db_version` WHERE `version`=@cNewVersion AND `structure`=@cNewStructure AND `content`=@cNewContent);

SELECT '* UPDATE COMPLETE *' AS `===== Status =====`,@cNewResult AS `===== DB is now on Version =====`;
END IF;
ELSE -- Current version is not the expected version
IF (@cCurResult = @cNewResult) THEN -- Does the current version match the new version
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cCurResult AS `===== DB is already on Version =====`;
ELSE -- Current version is not one related to this update
IF(@cCurResult IS NULL) THEN -- Something has gone wrong
SELECT '* UPDATE FAILED *' AS `===== Status =====`,'Unable to locate DB Version Information' AS `============= Error Message =============`;
ELSE
IF(@cOldResult IS NULL) THEN -- Something has gone wrong
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurStructure := (SELECT `STRUCTURE` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurContent := (SELECT `Content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurOutput = CONCAT(@cCurVersion, '_', @cCurStructure, '_', @cCurContent, ' - ',@cCurResult);
SET @cOldResult = CONCAT('Rel',@cOldVersion, '_', @cOldStructure, '_', @cOldContent, ' - ','IS NOT APPLIED');
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cOldResult AS `=== Expected ===`,@cCurOutput AS `===== Found Version =====`;
ELSE
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurStructure := (SELECT `STRUCTURE` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurContent := (SELECT `Content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1);
SET @cCurOutput = CONCAT(@cCurVersion, '_', @cCurStructure, '_', @cCurContent, ' - ',@cCurResult);
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cOldResult AS `=== Expected ===`,@cCurOutput AS `===== Found Version =====`;
END IF;
END IF;
END IF;
END IF;
END $$

DELIMITER ;

-- Execute the procedure
CALL update_mangos();

-- Drop the procedure
DROP PROCEDURE IF EXISTS `update_mangos`;


0 comments on commit f94176c

Please sign in to comment.