Skip to content

Commit e41a86d

Browse files
committed
fix(install): inconsistency in fresh 2.6.0 install
fix #822
1 parent 8909e4e commit e41a86d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

install/mysql/plugin_formcreator_empty.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
212212
`tag_type` enum('none','questions','specifics','questions_and_specific','questions_or_specific') NOT NULL DEFAULT 'none',
213213
`tag_questions` varchar(255) NOT NULL,
214214
`tag_specifics` varchar(255) NOT NULL,
215-
`category_rule` enum('none','answer') NOT NULL DEFAULT 'none',
215+
`category_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
216216
`category_question` int(11) NOT NULL DEFAULT '0',
217217
PRIMARY KEY (`id`),
218218
INDEX `tickettemplates_id` (`tickettemplates_id`)

install/update_2.5_2.6.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,23 @@ function plugin_formcreator_update_2_6(Migration $migration) {
109109
}
110110
unset($obj);
111111

112+
$enum_category_rule = "'".implode("', '", array_keys(PluginFormcreatorTargetTicket::getEnumCategoryRule()))."'";
113+
$table = 'glpi_plugin_formcreator_targettickets';
114+
if (!$DB->fieldExists($table, 'category_rule', false)) {
115+
$query = "ALTER TABLE `$table`
116+
ADD `category_rule` ENUM($enum_category_rule) NOT NULL DEFAULT 'none' AFTER `tag_specifics`;";
117+
$DB->query($query) or plugin_formcreator_upgrade_error($migration);
118+
} else {
119+
$current_enum_category_rule = PluginFormcreatorCommon::getEnumValues($table, 'category_rule');
120+
if (count($current_enum_category_rule) != count(PluginFormcreatorTargetTicket::getEnumCategoryRule())) {
121+
$query = "ALTER TABLE `$table`
122+
CHANGE COLUMN `category_rule` `category_rule`
123+
ENUM($enum_category_rule)
124+
NOT NULL DEFAULT 'none'";
125+
$DB->query($query) or plugin_formcreator_upgrade_error($migration);
126+
}
127+
}
128+
112129
$table = 'glpi_plugin_formcreator_items_targetchanges';
113130
$enum_urgency_rule = "'".implode("', '", array_keys(PluginFormcreatorTargetChange::getEnumUrgencyRule()))."'";
114131
$enum_category_rule = "'".implode("', '", array_keys(PluginFormcreatorTargetChange::getEnumCategoryRule()))."'";

0 commit comments

Comments
 (0)