From e7f5954c71af609abd2e1da26b3108b869c0db00 Mon Sep 17 00:00:00 2001 From: Wang Yan Date: Fri, 10 May 2019 17:08:52 +0800 Subject: [PATCH] Fix migrator scan all schedule from v1.7.0 (#7763) In v1.7.0, it creates an record for scan all but without cron string, just update the record with the cron in properties. Signed-off-by: wang yan --- make/migrations/postgresql/0004_1.8.0_schema.up.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/make/migrations/postgresql/0004_1.8.0_schema.up.sql b/make/migrations/postgresql/0004_1.8.0_schema.up.sql index e347e7218..1a179c647 100644 --- a/make/migrations/postgresql/0004_1.8.0_schema.up.sql +++ b/make/migrations/postgresql/0004_1.8.0_schema.up.sql @@ -166,7 +166,16 @@ If user set the scan all schedule, move it into table admin_job, and let the api DO $$ BEGIN IF exists(select * FROM properties WHERE k = 'scan_all_policy') then - INSERT INTO admin_job (job_name, job_kind, cron_str, status) VALUES ('IMAGE_SCAN_ALL', 'Periodic', (select v FROM properties WHERE k = 'scan_all_policy'), 'pending'); + /* + In v1.7.0, it creates an record for scan all but without cron string, just update the record with the cron in properties. + */ + IF exists(select * FROM admin_job WHERE job_name = 'IMAGE_SCAN_ALL' AND job_kind = 'Periodic' AND deleted = 'f') then + UPDATE admin_job SET cron_str=scan_all_cron.v + FROM (select * FROM properties WHERE k = 'scan_all_policy') AS scan_all_cron + WHERE job_name = 'IMAGE_SCAN_ALL' AND job_kind = 'Periodic' AND deleted = 'f'; + ELSE + INSERT INTO admin_job (job_name, job_kind, cron_str, status) VALUES ('IMAGE_SCAN_ALL', 'Periodic', (select v FROM properties WHERE k = 'scan_all_policy'), 'pending'); + END IF; DELETE FROM properties WHERE k='scan_all_policy'; END IF; END $$;