-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(revert-solution): Revert previous temporary solution
- Loading branch information
GeloPakDev1
authored and
GeloPakDev1
committed
Feb 5, 2024
1 parent
9523a3b
commit 05614a8
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/resources/templates/db_scripts/convertSeriesAndSubjects.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE OR REPLACE FUNCTION ${myuniversity}_${mymodule}.migrate_series_and_subjects(jsonb) RETURNS jsonb AS $$ | ||
DECLARE | ||
instance jsonb := $1; | ||
BEGIN | ||
IF jsonb_typeof(instance->'series'->0) = 'string' THEN | ||
instance = jsonb_set(instance, '{series}', | ||
(SELECT COALESCE(jsonb_agg(v), '[]') | ||
FROM (SELECT jsonb_build_object('value', jsonb_array_elements_text(instance->'series')) AS v) x)); | ||
END IF; | ||
IF jsonb_typeof(instance->'subjects'->0) = 'string' THEN | ||
instance = jsonb_set(instance, '{subjects}', | ||
(SELECT COALESCE(jsonb_agg(v), '[]') | ||
FROM (SELECT jsonb_build_object('value', jsonb_array_elements_text(instance->'subjects')) AS v) x)); | ||
END IF; | ||
RETURN instance; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters