From 000cdfdcfd5c382cba5c58cc71a25d61eb4cf549 Mon Sep 17 00:00:00 2001
From: Daniel Barbero Martin <daniel.barbero@artica.es>
Date: Thu, 4 Jul 2019 12:09:08 +0200
Subject: [PATCH] WIP failover

---
 pandora_console/extras/mr/30.sql                              | 1 -
 pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +-
 pandora_console/include/ajax/reporting.ajax.php               | 2 --
 pandora_console/pandoradb.sql                                 | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql
index 2de6e9cc19..eeb3b8d797 100644
--- a/pandora_console/extras/mr/30.sql
+++ b/pandora_console/extras/mr/30.sql
@@ -1,7 +1,6 @@
 START TRANSACTION;
 
 ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL;
-ALTER TABLE `treport_content_sla_combined` ADD `id_server_failover` int(10) unsigned NOT NULL;
 
 ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0';
 ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) 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 4404ee826d..60e19998e8 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
@@ -1451,6 +1451,7 @@ ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0';
 -- Table `tmodule_relationship`
 -- ---------------------------------------------------------------------
 ALTER TABLE tmodule_relationship ADD COLUMN `id_server` varchar(100) NOT NULL DEFAULT '';
+ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct';
 
 -- ---------------------------------------------------------------------
 -- Table `tpolicy_module`
@@ -2218,4 +2219,3 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` (
 -- Table `treport_content_sla_combined`
 -- ---------------------------------------------------------------------
 ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL;
-ALTER TABLE `treport_content_sla_combined` ADD `id_server_failover` int(10) unsigned NOT NULL;
diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php
index fa87ad72e0..dec331b6ef 100755
--- a/pandora_console/include/ajax/reporting.ajax.php
+++ b/pandora_console/include/ajax/reporting.ajax.php
@@ -66,7 +66,6 @@ if ($add_sla) {
     $sla_min = get_parameter('sla_min', 0);
     $server_id = (int) get_parameter('server_id', 0);
     $id_module_failover = (int) get_parameter('id_module_failover', 0);
-    $id_server_failover = (int) get_parameter('id_server_failover', 0);
 
     $id_service = (int) get_parameter('id_service');
     if (empty($id_module) && !empty($id_service)) {
@@ -94,7 +93,6 @@ if ($add_sla) {
             'sla_min'                  => $sla_min,
             'sla_limit'                => $sla_limit,
             'server_name'              => $connection['server_name'],
-            'id_server_failover'       => $id_server_failover,
         ]
     );
 
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 8b2123c66c..95d6caadfd 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -1468,7 +1468,6 @@ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
 	`id_report_content` INTEGER UNSIGNED NOT NULL,
 	`id_agent_module` int(10) unsigned NOT NULL,
 	`id_agent_module_failover` int(10) unsigned NOT NULL,
-	`id_server_failover` int(10) unsigned NOT NULL default 0,
 	`sla_max` double(18,2) NOT NULL default 0,
 	`sla_min` double(18,2) NOT NULL default 0,
 	`sla_limit` double(18,2) NOT NULL default 0,