From 994dbe8f9cac012add0614adf739797d677616fd Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 8 Sep 2020 21:12:59 +0200 Subject: [PATCH] FIX #14776 TIME 0:05 add template associations in outgoing template migration + test migration failed --- migration/20.03/migrateOutgoingTemplate.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/migration/20.03/migrateOutgoingTemplate.php b/migration/20.03/migrateOutgoingTemplate.php index 3e546253952..f0cedefacee 100644 --- a/migration/20.03/migrateOutgoingTemplate.php +++ b/migration/20.03/migrateOutgoingTemplate.php @@ -299,9 +299,11 @@ foreach ($customs as $custom) { $template['template_path'] = $storeResult['destination_dir']; $template['template_file_name'] = $storeResult['file_destination_name']; + $nextSequenceId = DatabaseModel::getNextSequenceValue(['sequenceId' => 'templates_seq']); DatabaseModel::insert([ 'table' => 'templates', 'columnsValues' => [ + 'template_id' => $nextSequenceId, 'template_label' => $template['template_label'] . ' (départ)', 'template_comment' => $template['template_comment'], 'template_content' => $template['template_content'], @@ -314,6 +316,24 @@ foreach ($customs as $custom) { 'template_file_name' => $template['template_file_name'], ] ]); + $templateAssociations = DatabaseModel::select([ + 'select' => ['value_field'], + 'table' => ['templates_association'], + 'where' => ['template_id = ?'], + 'data' => [$template['template_id']] + ]); + + $aValues = []; + foreach ($templateAssociations as $templateAssociation) { + $aValues[] = [$nextSequenceId, $templateAssociation['value_field']]; + } + if (!empty($aValues)) { + DatabaseModel::insertMultiple([ + 'table' => 'templates_association', + 'columns' => ['template_id', 'value_field'], + 'values' => $aValues + ]); + } } // END -- GitLab