-- DB update 2019_01_05_00 -> 2019_02_08_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_auth' AND COLUMN_NAME = '2019_01_05_00';
IF @COLEXISTS = 0 THEN LEAVE proc; END IF;
START TRANSACTION;
ALTER TABLE version_db_auth CHANGE COLUMN 2019_01_05_00 2019_02_08_00 bit;
SELECT sql_rev INTO OK FROM version_db_auth WHERE sql_rev = '1546018964238773800'; IF OK <> 'FALSE' THEN LEAVE proc; END IF;
--
-- START UPDATING QUERIES
--

INSERT INTO version_db_auth (`sql_rev`) VALUES ('1546018964238773800');
	
CREATE TABLE `logs_ip_actions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique Identifier',
`account_id` INT(10) UNSIGNED NOT NULL COMMENT 'Account ID',
`character_guid` INT(10) UNSIGNED NOT NULL COMMENT 'Character Guid',
`type` TINYINT(3) UNSIGNED NOT NULL,
`ip` VARCHAR(15) NOT NULL DEFAULT '127.0.0.1',
`systemnote` TEXT NULL COMMENT 'Notes inserted by system',
`unixtime` INT(10) UNSIGNED NOT NULL COMMENT 'Unixtime',
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp',
`comment` TEXT NULL COMMENT 'Allows users to add a comment',
PRIMARY KEY (`id`)
)
COMMENT='Used to log ips of individual actions'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

--
-- END UPDATING QUERIES
--
COMMIT;
END //
DELIMITER ;
CALL updateDb();
DROP PROCEDURE IF EXISTS `updateDb`;
