-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy path34604602_reference-5-1-1.up.sql
More file actions
39 lines (38 loc) · 1.23 KB
/
34604602_reference-5-1-1.up.sql
File metadata and controls
39 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- 1. Insert chart_ref if not exists
INSERT INTO "public"."chart_ref" (
"location", "version", "deployment_strategy_path",
"is_default", "active", "created_on", "created_by",
"updated_on", "updated_by", "name"
)
SELECT
'reference-chart_5-1-1', '5.1.1', 'pipeline-values.yaml',
'f', 't', now(), 1, now(), 1,
'Rollout Deployment'
WHERE NOT EXISTS (
SELECT 1
FROM "public"."chart_ref"
WHERE "version" = '5.1.1'
AND "location" = 'reference-chart_5-1-1'
AND "name" = 'Rollout Deployment'
);
-- 2. Insert mappings based on the chart_ref above
INSERT INTO global_strategy_metadata_chart_ref_mapping (
"global_strategy_metadata_id", "chart_ref_id", "active",
"created_on", "created_by", "updated_on", "updated_by", "default"
)
SELECT
m_ids.id,
cr.id,
true, now(), 1, now(), 1,
(m_ids.id = 1)
FROM
"public"."chart_ref" cr,
(VALUES (1), (2), (3), (4)) AS m_ids(id)
WHERE
cr.version = '5.1.1' AND cr.name = 'Rollout Deployment'
AND NOT EXISTS (
SELECT 1
FROM global_strategy_metadata_chart_ref_mapping existing
WHERE existing.global_strategy_metadata_id = m_ids.id
AND existing.chart_ref_id = cr.id
);