@@ -38,6 +38,7 @@ class PluginFormcreatorUpgradeTo2_13 {
3838 public function upgrade (Migration $ migration ) {
3939 $ this ->migration = $ migration ;
4040 $ this ->fixTables ();
41+ $ this ->updateShortText ();
4142 $ this ->migrateEntityConfig ();
4243 $ this ->addDefaultFormListMode ();
4344 $ this ->addDashboardVisibility ();
@@ -160,13 +161,30 @@ public function fixTables(): void {
160161 $ this ->migration ->migrationOneTable ($ table );
161162
162163 $ 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+ }
166170
167171 $ 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 ' );
170188 }
171189
172190 public function addEntityOption () {
@@ -399,6 +417,9 @@ protected function migrateFkToUnsignedInt() {
399417 ];
400418
401419 foreach ($ tables as $ table => $ fields ) {
420+ if (!$ DB ->tableExists ($ table )) {
421+ continue ;
422+ }
402423 foreach ($ fields as $ field ) {
403424 if ($ field == 'id ' ) {
404425 $ type = 'autoincrement ' ;
0 commit comments