-- DB update 2021_09_25_00 -> 2021_10_14_00
DROP PROCEDURE IF EXISTS `updateDb`;
DELIMITER //
CREATE PROCEDURE updateDb ()
proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE';
SELECT COUNT(*) INTO @COLEXISTS
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_characters' AND COLUMN_NAME = '2021_09_25_00';
IF @COLEXISTS = 0 THEN LEAVE proc; END IF;
START TRANSACTION;
ALTER TABLE version_db_characters CHANGE COLUMN 2021_09_25_00 2021_10_14_00 bit;
SELECT sql_rev INTO OK FROM version_db_characters WHERE sql_rev = '1634163696773334100'; IF OK <> 'FALSE' THEN LEAVE proc; END IF;
--
-- START UPDATING QUERIES
--

INSERT INTO `version_db_characters` (`sql_rev`) VALUES ('1634163696773334100');

--
DELETE FROM `updates` WHERE `name` IN ('2016_07_09_00.sql', '2016_08_14_00.sql', '2016_07_09_01.sql', '2016_07_10_00.sql', '2016_08_08_00.sql', '2016_07_30_00.sql', '2016_08_12_00.sql', '2016_08_15_00.sql', '2016_08_25_00.sql', '2016_11_18_00.sql', '2016_11_19_00.sql', '2019_12_09_00.sql', '2017_09_18_00.sql', '2018_12_23_00.sql', '2018_04_19_00.sql', '2019_05_15_00.sql', '2019_01_06_00.sql', '2018_08_08_00.sql', '2019_02_17_00.sql', '2019_05_12_00.sql', '2019_11_22_00.sql', '2020_01_04_00.sql');
INSERT INTO `updates` (`name`, `hash`, `state`, `timestamp`, `speed`) VALUES
('2016_07_09_00.sql', '6CB4253FF700E83A3FCB121714F32E4FFA70F0F4', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_08_14_00.sql', '38462AB366B96C1979F049A5FAF33A1C2DE25E65', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_07_09_01.sql', '5A20018FCAEC914DB359E807682F9B826865C2AB', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_07_10_00.sql', 'CA163905843EFB726CA838F463448E3833175F70', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_08_08_00.sql', '909B26A005C244E715027F8FF31D721D236403AF', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_07_30_00.sql', '7CEA690831DD7B6509FB165BD3C5BFF2138AB867', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_08_12_00.sql', '9902E3CD09738DA232C168AA374551C1DB2B902E', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_08_15_00.sql', '0490565BD304DC7CB73B5A1F4B2348BFD53B9C31', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_08_25_00.sql', '2318A3863066AD26B28F80C6ABC9DCCB86A136BA', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_11_18_00.sql', '0D4DB0CCC7D7ABF467B1B614E7A5FFCDD5E2A5A3', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2016_11_19_00.sql', '4981B8C9F2368AFB5EDB3160FF9CC63AFD9DB3D9', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_12_09_00.sql', '04D33DE31942314C86AC20EA39D74C44228E9819', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2017_09_18_00.sql', '393373BB3CB5525ECF5A69661170AE0B49677AC3', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2018_12_23_00.sql', '0135EE4A7AA472A4BB6F9B76BABE84F8A45645D2', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2018_04_19_00.sql', '1DFB571DEDBACAC579229C7365A2F52330BB84B4', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_05_15_00.sql', 'E2D51033471C04D47DA3C091B2FB7D2BBB816E8B', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_01_06_00.sql', '043ADFE28ABFBEA7304FCE95183C385646CF78D8', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2018_08_08_00.sql', '8623083F006C05A08D5B1322FF3EFE7304AEB6FC', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_02_17_00.sql', 'FF8DE7049A60865CBE70B9736A9B63296A3969DF', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_05_12_00.sql', '75DB225858A4D21DA92D21AC292A9DD9A5551BA5', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2019_11_22_00.sql', 'CA433BC426072EF7DDC555B086F65B17BB83CAF5', 'ARCHIVED', '2021-10-14 04:13:44', 1),
('2020_01_04_00.sql', '7DA0D914F60BE3827068447FE4EA6AA85266E328', 'ARCHIVED', '2021-10-14 04:13:44', 1);

DELETE FROM `updates_include` WHERE `path`='$/data/sql/archive/db_characters';
INSERT INTO `updates_include` (`path`, `state`) VALUES ('$/data/sql/archive/db_characters', 'ARCHIVED');
--
-- END UPDATING QUERIES
--
UPDATE version_db_characters SET date = '2021_10_14_00' WHERE sql_rev = '1634163696773334100';
COMMIT;
END //
DELIMITER ;
CALL updateDb();
DROP PROCEDURE IF EXISTS `updateDb`;
