Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 31d1129

Browse files
authored
Merge pull request #33 from Breeding-Insight/feature/BI-2109
BI-2109 - Create Sub-entity Dataset from UI
2 parents f9c8ca8 + 8e06edf commit 31d1129

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- See the NOTICE file distributed with this work for additional information
2+
-- regarding copyright ownership.
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
16+
-- Updates trial.additional_info to have a datasets array instead of just observationDatasetId.
17+
-- Leaves observationDatasetId in place out of an abundance of caution.
18+
-- Only updates rows that don't already have datasets key (just in case the code was updated prematurely).
19+
DO
20+
$$
21+
BEGIN
22+
UPDATE
23+
trial
24+
SET
25+
additional_info = additional_info
26+
|| JSONB_BUILD_OBJECT(
27+
'datasets',
28+
JSONB_BUILD_ARRAY(
29+
JSONB_BUILD_OBJECT(
30+
'id', additional_info->'observationDatasetId',
31+
'name', additional_info->'defaultObservationLevel',
32+
'level', '0'
33+
)
34+
)
35+
)
36+
WHERE
37+
additional_info->'datasets' IS NULL;
38+
END
39+
$$;

0 commit comments

Comments
 (0)