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 (#406)

[MODFIN-358] - Add tenantId to the locations schema for restrict by Fund functionality
  • Loading branch information
imerabishvili authored Apr 11, 2024
1 parent 37a57c3 commit 33cf0d1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
},
{
"id": "finance-storage.funds",
"version": "4.0",
"version": "5.0",
"handlers": [
{
"methods": ["GET"],
Expand Down
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 33cf0d1

Please sign in to comment.