diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index 0a6e837195..2a6de782c6 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -13,6 +13,18 @@ CREATE TABLE IF NOT EXISTS `talert_calendar` ( 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`) +) 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 `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; 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 b31b13875c..536aa8f22d 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 @@ -4045,6 +4045,18 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet_network` ( FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +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`) +) 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; + SET @insert_type = 3; SET @insert_name = 'IPAM Recon'; SET @insert_description = 'This script is used to automatically detect network hosts availability and name, used as Recon Custom Script in the recon task. Parameters used are:\n\n* custom_field1 = network. i.e.: 192.168.100.0/24\n* custom_field2 = associated IPAM network id. i.e.: 4. Please do not change this value, it is assigned automatically in IPAM management.\n\nSee documentation for more information.'; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 3a08bc06e7..0b320185df 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3941,6 +3941,16 @@ CREATE TABLE `tnode_relations` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tipam_network_location` +-- ---------------------------------------------------------------------- +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`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tipam_network` -- ---------------------------------------------------------------------- @@ -3949,7 +3959,7 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `network` varchar(100) NOT NULL default '', `name_network` varchar(255) default '', `description` text NOT NULL, - `location` tinytext NOT NULL, + `location` int(10) unsigned NULL, `id_recon_task` int(10) unsigned NOT NULL, `scan_interval` tinyint(2) default 1, `monitoring` tinyint(2) default 0, @@ -3957,7 +3967,8 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `lightweight_mode` tinyint(2) default 0, `users_operator` text, PRIMARY KEY (`id`), - FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE + FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, + FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------------------------------------------------