From f96cfab100a9dce400b5471a83f0db91acac35aa Mon Sep 17 00:00:00 2001 From: guanxiatao Date: Sun, 26 Apr 2020 21:14:04 +0800 Subject: [PATCH] Table notification_policy fix when updgrding to 2.0 Signed-off-by: guanxiatao --- .../postgresql/0030_2.0.0_schema.up.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/make/migrations/postgresql/0030_2.0.0_schema.up.sql b/make/migrations/postgresql/0030_2.0.0_schema.up.sql index 06a5889be0..768bb321f6 100644 --- a/make/migrations/postgresql/0030_2.0.0_schema.up.sql +++ b/make/migrations/postgresql/0030_2.0.0_schema.up.sql @@ -207,3 +207,20 @@ UPDATE quota_usage SET used = used - 'count'; /* make Clair and Trivy as reserved name for scanners in-tree */ UPDATE scanner_registration SET name = concat_ws('-', name, uuid) WHERE name IN ('Clair', 'Trivy') AND immutable = FALSE; UPDATE scanner_registration SET name = split_part(name, '-', 1) WHERE immutable = TRUE; + +/*update event types in table 'notification_policy'*/ +UPDATE notification_policy SET event_types = '["DOWNLOAD_CHART","DELETE_CHART","UPLOAD_CHART","DELETE_ARTIFACT","PULL_ARTIFACT","PUSH_ARTIFACT","SCANNING_FAILED","SCANNING_COMPLETED"]'; + +/*update event type in table 'notification_job'*/ +UPDATE notification_job +SET event_type = CASE + WHEN notification_job.event_type = 'downloadChart' THEN 'DOWNLOAD_CHART' + WHEN notification_job.event_type = 'deleteChart' THEN 'DELETE_CHART' + WHEN notification_job.event_type = 'uploadChart' THEN 'UPLOAD_CHART' + WHEN notification_job.event_type = 'deleteImage' THEN 'DELETE_ARTIFACT' + WHEN notification_job.event_type = 'pullImage' THEN 'PULL_ARTIFACT' + WHEN notification_job.event_type = 'pushImage' THEN 'PUSH_ARTIFACT' + WHEN notification_job.event_type = 'scanningFailed' THEN 'SCANNING_FAILED' + WHEN notification_job.event_type = 'scanningCompleted' THEN 'SCANNING_COMPLETED' + ELSE event_type +END;