Skip to content

Commit 7e75e08

Browse files
committed
update query if project id exists
1 parent 92785c4 commit 7e75e08

File tree

1 file changed

+8
-1
lines changed
  • microsetta_private_api/db/patches

1 file changed

+8
-1
lines changed

microsetta_private_api/db/patches/0142.sql

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44

55
WITH all_observations AS (
66
SELECT observation_id FROM barcodes.sample_observations
7+
),
8+
add_projects AS (
9+
SELECT project_id
10+
FROM (VALUES (118), (160)) AS np(project_id)
11+
WHERE EXISTS (
12+
SELECT 1 FROM barcodes.project WHERE project.project_id = np.project_id
13+
)
714
)
815
INSERT INTO barcodes.sample_observation_project_associations (observation_id, project_id)
916
SELECT observation_id, project_id
1017
FROM all_observations
11-
CROSS JOIN (VALUES (118), (160)) AS new_projects(project_id);
18+
CROSS JOIN add_projects;

0 commit comments

Comments
 (0)