Skip to content

Commit

Permalink
fix(install): create tables before filling them (#1234)
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry authored Dec 18, 2018
1 parent 43cf75c commit c08e299
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions install/upgrade_to_2.7.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ public function upgrade(Migration $migration) {
// Migrate regex question parameters
$table = 'glpi_plugin_formcreator_questions';
if ($DB->fieldExists($table, 'regex')) {
$DB->query(
"CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionregexes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_formcreator_questions_id` int(11) NOT NULL,
`regex` text DEFAULT NULL,
`fieldname` varchar(255) DEFAULT NULL,
`uuid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
$request = [
'FROM' => $table,
'WHERE' => ['fieldtype' => ['float', 'integer', 'text', 'textarea']]
Expand All @@ -134,6 +145,18 @@ public function upgrade(Migration $migration) {
// Migrate range question parameters
$table = 'glpi_plugin_formcreator_questions';
if ($DB->fieldExists($table, 'range_min')) {
$DB->query(
"CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionranges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_formcreator_questions_id` int(11) NOT NULL,
`range_min` varchar(255) DEFAULT NULL,
`range_max` varchar(255) DEFAULT NULL,
`fieldname` varchar(255) DEFAULT NULL,
`uuid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
$request = [
'FROM' => $table,
'WHERE' => ['fieldtype' => ['float', 'integer', 'checkboxes', 'multiselect', 'text']]
Expand Down

0 comments on commit c08e299

Please sign in to comment.