@@ -38,6 +38,7 @@ class PluginFormcreatorUpgradeTo2_13 {
38
38
public function upgrade (Migration $ migration ) {
39
39
$ this ->migration = $ migration ;
40
40
$ this ->fixTables ();
41
+ $ this ->updateShortText ();
41
42
$ this ->migrateEntityConfig ();
42
43
$ this ->addDefaultFormListMode ();
43
44
$ this ->addDashboardVisibility ();
@@ -160,13 +161,30 @@ public function fixTables(): void {
160
161
$ this ->migration ->migrationOneTable ($ table );
161
162
162
163
$ table = 'glpi_plugin_formcreator_questiondependencies ' ;
163
- $ this ->migration ->changeField ($ table , 'plugin_formcreator_questions_id ' , 'plugin_formcreator_questions_id ' , $ unsignedIntType );
164
- $ this ->migration ->changeField ($ table , 'plugin_formcreator_questions_id_2 ' , 'plugin_formcreator_questions_id_2 ' , $ unsignedIntType );
165
- $ this ->migration ->migrationOneTable ($ table );
164
+ if ($ DB ->tableExists ($ table )) {
165
+ // Table may be created at the very end when upgrading from < 2.12
166
+ $ this ->migration ->changeField ($ table , 'plugin_formcreator_questions_id ' , 'plugin_formcreator_questions_id ' , $ unsignedIntType );
167
+ $ this ->migration ->changeField ($ table , 'plugin_formcreator_questions_id_2 ' , 'plugin_formcreator_questions_id_2 ' , $ unsignedIntType );
168
+ $ this ->migration ->migrationOneTable ($ table );
169
+ }
166
170
167
171
$ table = 'glpi_plugin_formcreator_forms_languages ' ;
168
- $ this ->migration ->changeField ($ table , 'plugin_formcreator_forms_id ' , 'plugin_formcreator_forms_id ' , $ unsignedIntType );
169
- $ this ->migration ->migrationOneTable ($ table );
172
+ if ($ DB ->tableExists ($ table )) {
173
+ // Table may be created at the very end when upgrading from < 2.12
174
+ $ this ->migration ->changeField ($ table , 'plugin_formcreator_forms_id ' , 'plugin_formcreator_forms_id ' , $ unsignedIntType );
175
+ $ this ->migration ->migrationOneTable ($ table );
176
+ }
177
+ }
178
+
179
+ public function updateShortText () {
180
+ $ table = 'glpi_plugin_formcreator_categories ' ;
181
+ $ this ->migration ->changeField ($ table , 'comment ' , 'comment ' , 'mediumtext ' );
182
+
183
+ $ table = 'glpi_plugin_formcreator_formanswers ' ;
184
+ $ this ->migration ->changeField ($ table , 'comment ' , 'comment ' , 'mediumtext ' );
185
+
186
+ $ table = 'glpi_plugin_formcreator_questionregexes ' ;
187
+ $ this ->migration ->changeField ($ table , 'regex ' , 'regex ' , 'mediumtext ' );
170
188
}
171
189
172
190
public function addEntityOption () {
@@ -399,6 +417,9 @@ protected function migrateFkToUnsignedInt() {
399
417
];
400
418
401
419
foreach ($ tables as $ table => $ fields ) {
420
+ if (!$ DB ->tableExists ($ table )) {
421
+ continue ;
422
+ }
402
423
foreach ($ fields as $ field ) {
403
424
if ($ field == 'id ' ) {
404
425
$ type = 'autoincrement ' ;
0 commit comments