Skip to content

Commit cb252be

Browse files
authored
Merge pull request #10 from Breeding-Insight/bug/BI-2786
[BI-2786] Migration to remove treatments out of ou additionalInfo
2 parents b40584f + 9968f3f commit cb252be

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
WITH treatment_json AS (SELECT
2+
observation_unit_id,
3+
jsonb_agg(
4+
jsonb_build_object('factor', factor)
5+
) AS treatments
6+
FROM observation_unit_treatment
7+
GROUP BY observation_unit_id)
8+
9+
UPDATE observation_unit ou
10+
SET additional_info =
11+
jsonb_set(
12+
COALESCE(ou.additional_info, '{}'::jsonb),
13+
'{treatments}',
14+
tj.treatments,
15+
true
16+
)
17+
FROM treatment_json tj
18+
WHERE ou.id = tj.observation_unit_id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE observation_unit SET additional_info = additional_info - 'treatments';

0 commit comments

Comments
 (0)