Skip to content
Snippets Groups Projects
Commit e6b38573 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #11692 TIME 0:30 migrate linked resources

parent c412caf8
No related branches found
No related tags found
No related merge requests found
......@@ -23,3 +23,4 @@ php ./migrateCustomValues.php
php ./migrateVersionAttachments.php
php ./migrateContacts.php
php ./migrateTemplates.php
php ./migrateLinkedResources.php
<?php
use Resource\models\ResModel;
require '../../vendor/autoload.php';
chdir('../..');
$customs = scandir('custom');
foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue;
}
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$migrated = 0;
$links = \SrcCore\models\DatabaseModel::select([
'select' => ['res_parent', 'res_child'],
'table' => ['res_linked']
]);
foreach ($links as $link) {
$resParent = (string)$link['res_parent'];
$resChild = (string)$link['res_child'];
ResModel::update([
'postSet' => ['linked_resources' => "jsonb_insert(linked_resources, '{0}', '\"{$resChild}\"')"],
'where' => ['res_id = ?', "(linked_resources @> ?) = false"],
'data' => [(int)$resParent, "\"{$resChild}\""]
]);
ResModel::update([
'postSet' => ['linked_resources' => "jsonb_insert(linked_resources, '{0}', '\"{$resParent}\"')"],
'where' => ['res_id = ?', "(linked_resources @> ?) = false"],
'data' => [(int)$resChild, "\"{$resParent}\""]
]);
$migrated++;
}
printf("Migration des liaisons dans res_letterbox (CUSTOM {$custom}) : " . $migrated . " liaisons migrés.\n");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment