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;