From 2cbfca2cdd374aff406edb74df994db95f2267b8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 9 Dec 2021 13:51:20 +0100 Subject: [PATCH] mr rev + timap_sites --- pandora_console/extras/mr/51.sql | 43 +++++++++++-------- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 9 ++++ pandora_console/pandoradb.sql | 12 ++++++ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index 3398bed0c3..479305227d 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -12,31 +12,39 @@ ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGN ALTER TABLE tagente_modulo MODIFY debug_content TEXT; CREATE TABLE IF NOT EXISTS `talert_calendar` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL default '', - `id_group` INT(10) NOT NULL DEFAULT 0, - `description` text, - PRIMARY KEY (`id`), - UNIQUE (`name`) + `id_group` INT(10) NOT NULL DEFAULT 0, + `description` text, + PRIMARY KEY (`id`), + UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); - CREATE TABLE IF NOT EXISTS `tipam_network_location` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE (`name`) + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`.`id` ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; -UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE; - +ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`; ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1; ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0; +ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; +ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday'; UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday'; UPDATE `talert_special_days` set `day_code` = 3 WHERE `same_day` = 'wednesday'; @@ -45,11 +53,8 @@ UPDATE `talert_special_days` set `day_code` = 5 WHERE `same_day` = 'friday'; UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday'; UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday'; -ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; -ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`; - +INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; +UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; UPDATE `tconfig` c1 JOIN (select count(*) as n FROM `tconfig` c2 WHERE (c2.`token` = "node_metaconsole" AND c2.`value` = 1) OR (c2.`token` = "centralized_management" AND c2.`value` = 1) ) v SET c1. `value` = 0 WHERE c1.token = "autocreate_remote_users" AND v.n = 2; COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ba0c0c32e3..a385b8def0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -4052,6 +4052,15 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` ( UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f8b675c9d6..48c7c4a6d2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3959,6 +3959,18 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` ( UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tipam_sites` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tipam_network` -- ----------------------------------------------------------------------