From 133b91858f5524a499534962bf8c264c5265f401 Mon Sep 17 00:00:00 2001 From: Azizbek Khushvakov <113523904+azizbekxm@users.noreply.github.com> Date: Fri, 22 Nov 2024 19:11:02 +0500 Subject: [PATCH] [MODFISTO-511] - Update script to avoid duplication issue (#437) * Update script * Fix script * Update script * Update script --- .../migration/extract_credits_from_expenditures.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql b/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql index 5a5cf588..4b18f8f0 100644 --- a/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql +++ b/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql @@ -40,11 +40,14 @@ WITH aggregated_amounts AS ( ) UPDATE ${myuniversity}_${mymodule}.transaction AS encumbrance SET - jsonb = jsonb || jsonb_build_object( - 'encumbrance', jsonb_build_object( - 'amountExpended', to_jsonb(aggregated_amounts.total_expended), - 'amountCredited', to_jsonb(aggregated_amounts.total_credited) - ) + jsonb = jsonb_set( + jsonb_set( + encumbrance.jsonb, + '{encumbrance,amountExpended}', + to_jsonb(aggregated_amounts.total_expended) + ), + '{encumbrance,amountCredited}', + to_jsonb(aggregated_amounts.total_credited) ) FROM aggregated_amounts WHERE encumbrance.id = aggregated_amounts.encumbrance_id;