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 <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2019-05-10 17:08:52 +08:00 committed by GitHub
parent d81afe274c
commit e7f5954c71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 $$;