@@ -155,6 +155,19 @@ public function upgrade(Migration $migration) {
155155 $ migration ->dropField ($ table , 'requesttype ' );
156156
157157 // Merge targettickets_actors and targetchanges_actors
158+ // Need a new table now
159+ $ DB ->query ("CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targets_actors` (
160+ `id` int(11) NOT NULL AUTO_INCREMENT,
161+ `itemtype` varchar(255) DEFAULT NULL,
162+ `items_id` int(11) NOT NULL,
163+ `actor_role` int(11) NOT NULL DEFAULT '1',
164+ `actor_type` int(11) NOT NULL DEFAULT '1',
165+ `actor_value` int(11) DEFAULT NULL,
166+ `use_notification` tinyint(1) NOT NULL DEFAULT '1',
167+ `uuid` varchar(255) DEFAULT NULL,
168+ PRIMARY KEY (`id`),
169+ INDEX `item` (`itemtype`, `items_id`)
170+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; " );
158171 $ this ->migrateTargetTicket_Actor ();
159172 $ this ->migrateTargetChange_Actor ();
160173 $ this ->addCaptchaOption ();
@@ -252,20 +265,12 @@ public function migrateTargetTicket_Actor() {
252265 if (!$ DB ->tableExists ($ table )) {
253266 return ;
254267 }
255-
256- $ result = $ DB ->request ([
257- 'FROM ' => $ table
258- ]);
259- $ table = 'glpi_plugin_formcreator_targets_actors ' ;
260- foreach ($ result as $ row ) {
261- $ row ['itemtype ' ] = PluginFormcreatorTargetTicket::class;
262- $ row ['items_id ' ] = $ row ['plugin_formcreator_targettickets_id ' ];
263- unset($ row ['plugin_formcreator_targettickets_id ' ]);
264- unset($ row ['id ' ]);
265- $ DB ->insert ($ table , $ row );
266- }
267-
268- $ table = 'glpi_plugin_formcreator_targettickets_actors ' ;
268+ $ DB ->query (
269+ "INSERT INTO `glpi_plugin_formcreator_targets_actors`
270+ (`itemtype`, `items_id`, `actor_role`, `actor_type`, `actor_value`, `use_notification`, `uuid`)
271+ SELECT 'PluginFormcreatorTargetTicket', `plugin_formcreator_targettickets_id`, `actor_role`, `actor_type`, `actor_value`, `use_notification`, `uuid`
272+ FROM ` $ table` "
273+ );
269274 $ this ->migration ->backupTables ([$ table ]);
270275 }
271276
@@ -277,19 +282,12 @@ public function migrateTargetChange_Actor() {
277282 return ;
278283 }
279284
280- $ result = $ DB ->request ([
281- 'FROM ' => $ table
282- ]);
283- $ table = 'glpi_plugin_formcreator_targets_actors ' ;
284- foreach ($ result as $ row ) {
285- $ row ['itemtype ' ] = PluginFormcreatorTargetChange::class;
286- $ row ['items_id ' ] = $ row ['plugin_formcreator_targettickets_id ' ];
287- unset($ row ['plugin_formcreator_targettickets_id ' ]);
288- unset($ row ['id ' ]);
289- $ DB ->insert ($ table , $ row );
290- }
291-
292- $ table = 'glpi_plugin_formcreator_targetchanges_actors ' ;
285+ $ DB ->query (
286+ "INSERT INTO `glpi_plugin_formcreator_targets_actors`
287+ (`itemtype`, `items_id`, `actor_role`, `actor_type`, `actor_value`, `use_notification`, `uuid`)
288+ SELECT 'PluginFormcreatorTargetChange', `plugin_formcreator_targetchanges_id`, `actor_role`, `actor_type`, `actor_value`, `use_notification`, `uuid`
289+ FROM ` $ table` "
290+ );
293291 $ this ->migration ->backupTables ([$ table ]);
294292 }
295293
0 commit comments