Skip to content

Commit a62fa8c

Browse files
Updated up migration
1 parent 57e0ea5 commit a62fa8c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
INSERT INTO "public"."chart_ref" ("location", "version", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by", "name","deployment_strategy_path") VALUES
2-
('cronjob-chart_1-6-0', '1.6.0', 'f', 't', 'now()', 1, 'now()', 1, 'Job & CronJob','pipeline-values.yaml');
1+
-- First, safely insert the chart reference if it doesn't already exist.
2+
INSERT INTO "public"."chart_ref" ("location", "version", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by", "name", "deployment_strategy_path")
3+
SELECT 'cronjob-chart_1-6-0', '1.6.0', 'f', 't', 'now()', 1, 'now()', 1, 'Job & CronJob', 'pipeline-values.yaml'
4+
WHERE NOT EXISTS (
5+
SELECT 1 FROM "public"."chart_ref" WHERE "location" = 'cronjob-chart_1-6-0'
6+
);
37

4-
INSERT INTO global_strategy_metadata_chart_ref_mapping ("global_strategy_metadata_id","chart_ref_id", "active","default","created_on", "created_by", "updated_on", "updated_by") VALUES
5-
((select id from global_strategy_metadata where name='ROLLING') ,(select id from chart_ref where location='cronjob-chart_1-6-0'), true,true,now(), 1, now(), 1);
8+
-- Next, safely insert the mapping if it doesn't already exist.
9+
INSERT INTO "public"."global_strategy_metadata_chart_ref_mapping" ("global_strategy_metadata_id", "chart_ref_id", "active", "default", "created_on", "created_by", "updated_on", "updated_by")
10+
SELECT
11+
(SELECT "id" FROM "public"."global_strategy_metadata" WHERE "name" = 'ROLLING'),
12+
(SELECT "id" FROM "public"."chart_ref" WHERE "location" = 'cronjob-chart_1-6-0'),
13+
true, true, 'now()', 1, 'now()', 1
14+
WHERE NOT EXISTS (
15+
SELECT 1
16+
FROM "public"."global_strategy_metadata_chart_ref_mapping"
17+
WHERE "global_strategy_metadata_id" = (SELECT "id" FROM "public"."global_strategy_metadata" WHERE "name" = 'ROLLING')
18+
AND "chart_ref_id" = (SELECT "id" FROM "public"."chart_ref" WHERE "location" = 'cronjob-chart_1-6-0')
19+
);

0 commit comments

Comments
 (0)