Skip to content

Commit 46ac7ad

Browse files
committed
fix(install): database schema inconsistencies between instal and upgrade
1 parent 03b7001 commit 46ac7ad

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

RoboFilePlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class RoboFilePlugin extends \Robo\Tasks
3838
'/vendor/',
3939
'/node_modules/',
4040
'/lib/',
41-
'/development/'
41+
'/development/',
42+
'/output/',
4243
];
4344
protected $csfiles = ['./'];
4445

install/mysql/plugin_formcreator_empty.sql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_entityconfigs` (
3535

3636
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms` (
3737
`id` int(11) NOT NULL AUTO_INCREMENT,
38-
`name` varchar(255) NOT NULL,
38+
`name` varchar(255) NOT NULL DEFAULT '',
3939
`entities_id` int(11) NOT NULL DEFAULT '0',
4040
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
4141
`access_rights` tinyint(1) NOT NULL DEFAULT '1',
@@ -64,8 +64,8 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` (
6464
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
6565
`plugin_formcreator_forms_id` int(11) NOT NULL,
6666
`requester_id` int(11) DEFAULT NULL,
67-
`users_id_validator` int(11) DEFAULT NULL,
68-
`groups_id_validator` int(11) DEFAULT NULL,
67+
`users_id_validator` int(11) NOT NULL DEFAULT '0',
68+
`groups_id_validator` int(11) NOT NULL DEFAULT '0',
6969
`request_date` datetime NOT NULL,
7070
`status` enum('waiting','refused','accepted') NOT NULL DEFAULT 'waiting',
7171
`comment` text,
@@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_validators` (
9898

9999
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questions` (
100100
`id` int(11) NOT NULL AUTO_INCREMENT,
101-
`name` varchar(255) NOT NULL,
101+
`name` varchar(255) NOT NULL DEFAULT '',
102102
`plugin_formcreator_sections_id` int(11) NOT NULL,
103103
`fieldtype` varchar(30) NOT NULL DEFAULT 'text',
104104
`required` tinyint(1) NOT NULL DEFAULT '0',
@@ -129,7 +129,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questions_conditions` (
129129

130130
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_sections` (
131131
`id` int(11) NOT NULL AUTO_INCREMENT,
132-
`name` varchar(255) NOT NULL,
132+
`name` varchar(255) NOT NULL DEFAULT '',
133133
`plugin_formcreator_forms_id` int(11) NOT NULL,
134134
`order` int(11) NOT NULL DEFAULT '0',
135135
`uuid` varchar(255) DEFAULT NULL,
@@ -153,7 +153,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targetchanges` (
153153
`urgency_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
154154
`urgency_question` int(11) NOT NULL DEFAULT '0',
155155
`validation_followup` tinyint(1) NOT NULL DEFAULT '1',
156-
`destination_entity` enum('current','requester','requester_dynamic_first','requester_dynamic_last','form','validator','specific','user','entity') NOT NULL DEFAULT 'requester',
156+
`destination_entity` enum('current','requester','requester_dynamic_first','requester_dynamic_last','form','validator','specific','user','entity') NOT NULL DEFAULT 'current',
157157
`destination_entity_value` int(11) DEFAULT NULL,
158158
`tag_type` enum('none','questions','specifics','questions_and_specific','questions_or_specific') NOT NULL DEFAULT 'none',
159159
`tag_questions` varchar(255) NOT NULL,
@@ -198,8 +198,6 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
198198
`due_date_period` enum('minute','hour','day','month') DEFAULT NULL,
199199
`urgency_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
200200
`urgency_question` int(11) NOT NULL DEFAULT '0',
201-
`location_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
202-
`location_question` int(11) NOT NULL DEFAULT '0',
203201
`validation_followup` tinyint(1) NOT NULL DEFAULT '1',
204202
`destination_entity` enum('current','requester','requester_dynamic_first','requester_dynamic_last','form','validator','specific','user','entity') NOT NULL DEFAULT 'current',
205203
`destination_entity_value` int(11) DEFAULT NULL,
@@ -208,6 +206,9 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
208206
`tag_specifics` varchar(255) NOT NULL,
209207
`category_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
210208
`category_question` int(11) NOT NULL DEFAULT '0',
209+
`uuid` varchar(255) DEFAULT NULL,
210+
`location_rule` enum('none','specific','answer') NOT NULL DEFAULT 'none',
211+
`location_question` int(11) NOT NULL DEFAULT '0',
211212
PRIMARY KEY (`id`),
212213
INDEX `tickettemplates_id` (`tickettemplates_id`)
213214
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

install/upgrade_to_2.6.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public function upgrade(Migration $migration) {
123123
// Fix bad foreign key
124124
$table = 'glpi_plugin_formcreator_answers';
125125
$migration->changeField($table, 'plugin_formcreator_question_id', 'plugin_formcreator_questions_id', 'integer');
126+
$migration->dropKey($table, 'plugin_formcreator_question_id');
127+
$migration->addKey($table, 'plugin_formcreator_questions_id', 'plugin_formcreator_questions_id');
126128

127129
$table = 'glpi_plugin_formcreator_items_targettickets';
128130
if (!$DB->tableExists($table)) {

tests/src/CommonTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ protected function _checkTargetTicket($targetticket = []) {
405405
'category_question',
406406
'_actors',
407407
'_ticket_relations',
408+
'uuid',
408409
];
409410
$this->array($targetticket)->notHasKeys([
410411
'id',

tests/suite-uninstall/Config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,4 @@ public function testUninstallPlugin() {
9999
// - NotificationTemplateTranslation
100100
// - Notification_NotificationTemplate
101101
}
102-
103102
}

0 commit comments

Comments
 (0)