Skip to content

Commit 7420cdc

Browse files
committed
fix(install): less picky checks when upgrading from 2.13.0
1 parent 4ba5ed8 commit 7420cdc

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

install/install.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,7 @@ public function upgrade(Migration $migration, $args = []): bool {
145145
$log = '';
146146
if ($oldVersion !== null) {
147147
$checkResult = true;
148-
if (version_compare($oldVersion, '2.13.0') < 0) {
149-
// Upgrading from GLPI 9.5 to GLPI 10
150-
// check only columns format
151-
$checkResult = $this->checkSchema(
152-
$oldVersion,
153-
true,
154-
false,
155-
false,
156-
true,
157-
true,
158-
true,
159-
$log
160-
);
161-
} else {
148+
if (version_compare($oldVersion, '2.13.0') >= 0) {
162149
// more strict DB check : dynamic rows, utf8mb4, unsigned int for foreign keys
163150
$checkResult = $this->checkSchema(
164151
$oldVersion,
@@ -170,6 +157,19 @@ public function upgrade(Migration $migration, $args = []): bool {
170157
false,
171158
$log
172159
);
160+
} else {
161+
// Upgrading from GLPI 9.5 to GLPI 10
162+
// check only columns format
163+
// $checkResult = $this->checkSchema(
164+
// $oldVersion,
165+
// true,
166+
// false,
167+
// false,
168+
// true,
169+
// true,
170+
// true,
171+
// $log
172+
// );
173173
}
174174
if (!$checkResult) {
175175
if (!isCommandLine()) {

install/upgrade_to_2.13.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ public function fixTables(): void {
6666
global $DB;
6767
// Based on schema from version 2.12.5, try to fix some harlmess inconsistencies
6868

69+
$unsignedIntType = "INT " . DBConnection::getDefaultPrimaryKeySignOption() . " NOT NULL DEFAULT 0";
70+
6971
$table = 'glpi_plugin_formcreator_answers';
70-
$this->migration->changeField($table, 'plugin_formcreator_formanswers_id', 'plugin_formcreator_formanswers_id', 'integer');
71-
$this->migration->changeField($table, 'plugin_formcreator_questions_id', 'plugin_formcreator_questions_id', 'integer');
72+
$this->migration->changeField($table, 'plugin_formcreator_formanswers_id', 'plugin_formcreator_formanswers_id', $unsignedIntType);
73+
$this->migration->changeField($table, 'plugin_formcreator_questions_id', 'plugin_formcreator_questions_id', $unsignedIntType);
7274
$this->migration->migrationOneTable($table);
7375

7476
$table = 'glpi_plugin_formcreator_forms';
@@ -87,8 +89,8 @@ public function fixTables(): void {
8789
['groups_id_validator' => '0'],
8890
['groups_id_validator' => null]
8991
);
90-
$this->migration->changeField($table, 'users_id_validator', 'users_id_validator', 'integer');
91-
$this->migration->changeField($table, 'groups_id_validator', 'groups_id_validator', 'integer');
92+
$this->migration->changeField($table, 'users_id_validator', 'users_id_validator', $unsignedIntType);
93+
$this->migration->changeField($table, 'groups_id_validator', 'groups_id_validator', $unsignedIntType);
9294
$this->migration->migrationOneTable($table);
9395

9496
$table = 'glpi_plugin_formcreator_questions';
@@ -112,33 +114,33 @@ public function fixTables(): void {
112114
);
113115
$this->migration->changeField($table, 'validation_followup', 'validation_followup', 'bool', ['after' => 'urgency_question', 'value' => '1']);
114116
$this->migration->changeField($table, 'destination_entity', 'destination_entity', 'integer', ['after' => 'validation_followup', 'value' => '1']);
115-
$this->migration->changeField($table, 'destination_entity_value', 'destination_entity_value', 'integer', ['after' => 'destination_entity', 'default' => '1']);
117+
$this->migration->changeField($table, 'destination_entity_value', 'destination_entity_value', $unsignedIntType, ['after' => 'destination_entity', 'default' => '1']);
116118
$this->migration->changeField($table, 'tag_type', 'tag_type', 'integer', ['after' => 'destination_entity_value', 'value' => '1']);
117119
$this->migration->changeField($table, 'tag_questions', 'tag_questions', 'string', ['after' => 'tag_type']);
118120
$this->migration->changeField($table, 'tag_specifics', 'tag_specifics', 'string', ['after' => 'tag_questions']);
119121
$this->migration->changeField($table, 'category_rule', 'category_rule', 'integer', ['after' => 'tag_specifics', 'value' => '1']);
120122
$this->migration->changeField($table, 'category_question', 'category_question', 'integer', ['after' => 'category_rule']);
121123
$this->migration->changeField($table, 'associate_rule', 'associate_rule', 'integer', ['after' => 'category_question', 'value' => '1']);
122-
$this->migration->changeField($table, 'associate_question', 'associate_question', 'integer', ['after' => 'associate_rule']);
124+
$this->migration->changeField($table, 'associate_question', 'associate_question', $unsignedIntType, ['after' => 'associate_rule']);
123125
$this->migration->changeField($table, 'location_rule', 'location_rule', 'integer', ['after' => 'associate_question', 'value' => '1']);
124-
$this->migration->changeField($table, 'location_question', 'location_question', 'integer', ['after' => 'location_rule']);
126+
$this->migration->changeField($table, 'location_question', 'location_question', $unsignedIntType, ['after' => 'location_rule']);
125127
$this->migration->changeField($table, 'show_rule', 'show_rule', 'integer', ['after' => 'location_question', 'value' => '1']);
126128
$this->migration->changeField($table, 'sla_rule', 'sla_rule', 'integer', ['after' => 'show_rule', 'value' => '1']);
127-
$this->migration->changeField($table, 'sla_question_tto', 'sla_question_tto', 'integer', ['after' => 'sla_rule']);
128-
$this->migration->changeField($table, 'sla_question_ttr', 'sla_question_ttr', 'integer', ['after' => 'sla_question_tto']);
129+
$this->migration->changeField($table, 'sla_question_tto', 'sla_question_tto', $unsignedIntType, ['after' => 'sla_rule']);
130+
$this->migration->changeField($table, 'sla_question_ttr', 'sla_question_ttr', $unsignedIntType, ['after' => 'sla_question_tto']);
129131
$this->migration->changeField($table, 'ola_rule', 'ola_rule', 'integer', ['after' => 'sla_question_ttr', 'value' => '1']);
130-
$this->migration->changeField($table, 'ola_question_tto', 'ola_question_tto', 'integer', ['after' => 'ola_rule']);
131-
$this->migration->changeField($table, 'ola_question_ttr', 'ola_question_ttr', 'integer', ['after' => 'ola_question_tto']);
132+
$this->migration->changeField($table, 'ola_question_tto', 'ola_question_tto', $unsignedIntType, ['after' => 'ola_rule']);
133+
$this->migration->changeField($table, 'ola_question_ttr', 'ola_question_ttr', $unsignedIntType, ['after' => 'ola_question_tto']);
132134
$this->migration->changeField($table, 'uuid', 'uuid', 'string', ['after' => 'ola_question_ttr']);
133135
$this->migration->migrationOneTable($table);
134136

135137
$table = 'glpi_plugin_formcreator_questiondependencies';
136-
$this->migration->changeField($table, 'plugin_formcreator_questions_id', 'plugin_formcreator_questions_id', 'integer');
137-
$this->migration->changeField($table, 'plugin_formcreator_questions_id_2', 'plugin_formcreator_questions_id_2', 'integer');
138+
$this->migration->changeField($table, 'plugin_formcreator_questions_id', 'plugin_formcreator_questions_id', $unsignedIntType);
139+
$this->migration->changeField($table, 'plugin_formcreator_questions_id_2', 'plugin_formcreator_questions_id_2', $unsignedIntType);
138140
$this->migration->migrationOneTable($table);
139141

140142
$table = 'glpi_plugin_formcreator_forms_languages';
141-
$this->migration->changeField($table, 'plugin_formcreator_forms_id', 'plugin_formcreator_forms_id', 'integer');
143+
$this->migration->changeField($table, 'plugin_formcreator_forms_id', 'plugin_formcreator_forms_id', $unsignedIntType);
142144
$this->migration->migrationOneTable($table);
143145
}
144146

0 commit comments

Comments
 (0)