@@ -155,6 +155,19 @@ public function upgrade(Migration $migration) {
155
155
$ migration ->dropField ($ table , 'requesttype ' );
156
156
157
157
// 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; " );
158
171
$ this ->migrateTargetTicket_Actor ();
159
172
$ this ->migrateTargetChange_Actor ();
160
173
$ this ->addCaptchaOption ();
@@ -252,20 +265,12 @@ public function migrateTargetTicket_Actor() {
252
265
if (!$ DB ->tableExists ($ table )) {
253
266
return ;
254
267
}
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
+ );
269
274
$ this ->migration ->backupTables ([$ table ]);
270
275
}
271
276
@@ -277,19 +282,12 @@ public function migrateTargetChange_Actor() {
277
282
return ;
278
283
}
279
284
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
+ );
293
291
$ this ->migration ->backupTables ([$ table ]);
294
292
}
295
293
0 commit comments