Skip to content

Commit

Permalink
[MODFIN-358] - Add tenantId to the locations schema for restrict by F…
Browse files Browse the repository at this point in the history
…und functionality
  • Loading branch information
imerabishvili committed Apr 8, 2024
1 parent 37a57c3 commit f415254
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ CREATE OR REPLACE FUNCTION ${myuniversity}_${mymodule}.budget_encumbrances_rollo
'fundTypeName', fund_type->'name',
'acqUnitIds', fund->'acqUnitIds',
'donorOrganizationIds', fund->'donorOrganizationIds',
'locationIds', fund->'locationIds',
'locations', fund->'locations',
'allocatedFromIds', fund->'allocatedFromIds',
'allocatedFromNames', allocatedFromNames,
'allocatedToIds', fund->'allocatedToIds',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Transform locationIds arrays to array of objects with locationId field inside them
UPDATE ${myuniversity}_${mymodule}.fund
SET jsonb = jsonb - 'locationIds' || jsonb_build_object(
'locations',
CASE WHEN jsonb->>'locationIds' = '[]' THEN '[]' ELSE
(SELECT jsonb_agg(jsonb_build_object('locationId', value)) from jsonb_array_elements(jsonb->'locationIds')) END
)
WHERE jsonb ? 'locationIds';
5 changes: 5 additions & 0 deletions src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
"run": "after",
"snippetPath": "migration/update_budget_rollover.sql",
"fromModuleVersion": "mod-finance-storage-8.4.0"
},
{
"run": "after",
"snippetPath": "migration/transform_location_ids_array.sql",
"fromModuleVersion": "mod-finance-storage-8.7.0"
}
],
"tables": [
Expand Down

0 comments on commit f415254

Please sign in to comment.