From 7c7704cdd1417fe367ec115fafaeae5ea4aa2f1f Mon Sep 17 00:00:00 2001 From: cigamit Date: Fri, 28 Apr 2017 04:35:36 -0500 Subject: [PATCH] Make upgrade repeatable --- install/1_1_5_to_1_1_6.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/install/1_1_5_to_1_1_6.php b/install/1_1_5_to_1_1_6.php index 793bbe78ac..ef84c835d5 100644 --- a/install/1_1_5_to_1_1_6.php +++ b/install/1_1_5_to_1_1_6.php @@ -23,15 +23,26 @@ */ function upgrade_to_1_1_6() { - db_install_execute('ALTER TABLE `data_input` MODIFY COLUMN `input_string` varchar(512) default NULL'); - - db_install_execute("ALTER TABLE `snmp_query_graph` ADD KEY `graph_template_id_name` (`graph_template_id`, `name`)"); - - db_install_execute( - "ALTER TABLE `graph_templates` - ADD `multiple` TINYINT(1) UNSIGNED NULL DEFAULT '0' AFTER `name`, - ADD KEY `multiple_name` (`multiple`, `name`)" + db_install_execute('ALTER TABLE `data_input` + MODIFY COLUMN `input_string` varchar(512) default NULL' ); - db_execute_prepared("UPDATE graph_templates SET multiple = 1 WHERE hash = '010b90500e1fc6a05abfd542940584d0'"); + if (!db_index_exists('snmp_query_graph', 'graph_template_id_name')) { + db_install_execute("ALTER TABLE `snmp_query_graph` + ADD INDEX `graph_template_id_name` (`graph_template_id`, `name`)" + ); + } + + if (!db_index_exists('graph_templates', 'multiple_name')) { + db_install_execute( + "ALTER TABLE `graph_templates` + ADD `multiple` TINYINT(1) UNSIGNED NULL DEFAULT '0' AFTER `name`, + ADD KEY `multiple_name` (`multiple`, `name`)" + ); + } + + db_execute_prepared("UPDATE graph_templates + SET multiple = 1 + WHERE hash = '010b90500e1fc6a05abfd542940584d0'" + ); }