mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-18 04:41:26 +01:00
fix 2.8 migration issue (#18389)
The sql must be idempotent Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
6590fe8eef
commit
c1d297b015
@ -2,7 +2,7 @@
|
|||||||
delete from artifact_blob afb where not exists (select digest from blob b where b.digest = afb.digest_af);
|
delete from artifact_blob afb where not exists (select digest from blob b where b.digest = afb.digest_af);
|
||||||
|
|
||||||
/* add subject_artifact_digest*/
|
/* add subject_artifact_digest*/
|
||||||
alter table artifact_accessory add column subject_artifact_digest varchar(1024);
|
alter table artifact_accessory add column IF NOT EXISTS subject_artifact_digest varchar(1024);
|
||||||
|
|
||||||
DO $$
|
DO $$
|
||||||
DECLARE
|
DECLARE
|
||||||
@ -16,9 +16,19 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
alter table artifact_accessory drop CONSTRAINT artifact_accessory_subject_artifact_id_fkey;
|
alter table artifact_accessory drop CONSTRAINT IF EXISTS artifact_accessory_subject_artifact_id_fkey;
|
||||||
alter table artifact_accessory drop CONSTRAINT unique_artifact_accessory;
|
alter table artifact_accessory drop CONSTRAINT IF EXISTS unique_artifact_accessory;
|
||||||
alter table artifact_accessory add CONSTRAINT unique_artifact_accessory UNIQUE (artifact_id, subject_artifact_digest);
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1
|
||||||
|
FROM pg_constraint
|
||||||
|
WHERE conname = 'unique_artifact_accessory')
|
||||||
|
THEN
|
||||||
|
ALTER TABLE artifact_accessory
|
||||||
|
ADD CONSTRAINT unique_artifact_accessory UNIQUE (artifact_id, subject_artifact_digest);
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
|
||||||
/* Update the registry and replication policy associated with the chartmuseum */
|
/* Update the registry and replication policy associated with the chartmuseum */
|
||||||
UPDATE registry
|
UPDATE registry
|
||||||
@ -91,6 +101,7 @@ DECLARE
|
|||||||
exec_id integer;
|
exec_id integer;
|
||||||
extra_attrs json;
|
extra_attrs json;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
if exists (select 1 from information_schema.tables where table_name = 'notification_job') then
|
||||||
FOR job_group IN SELECT DISTINCT policy_id,event_type FROM notification_job WHERE event_type NOT IN ('UPLOAD_CHART', 'DOWNLOAD_CHART', 'DELETE_CHART')
|
FOR job_group IN SELECT DISTINCT policy_id,event_type FROM notification_job WHERE event_type NOT IN ('UPLOAD_CHART', 'DOWNLOAD_CHART', 'DELETE_CHART')
|
||||||
LOOP
|
LOOP
|
||||||
SELECT * INTO job FROM notification_job WHERE
|
SELECT * INTO job FROM notification_job WHERE
|
||||||
@ -125,7 +136,9 @@ BEGIN
|
|||||||
INSERT INTO execution (vendor_type,vendor_id,status,trigger,extra_attrs,start_time,end_time,update_time) VALUES (vendor_type,job.policy_id,new_status,'EVENT',extra_attrs,job.creation_time,job.update_time,job.update_time) RETURNING id INTO exec_id;
|
INSERT INTO execution (vendor_type,vendor_id,status,trigger,extra_attrs,start_time,end_time,update_time) VALUES (vendor_type,job.policy_id,new_status,'EVENT',extra_attrs,job.creation_time,job.update_time,job.update_time) RETURNING id INTO exec_id;
|
||||||
INSERT INTO task (execution_id,job_id,status,status_code,run_count,creation_time,start_time,update_time,end_time,vendor_type) VALUES (exec_id,job.job_uuid,new_status,status_code,1,job.creation_time,job.update_time,job.update_time,job.update_time,vendor_type);
|
INSERT INTO task (execution_id,job_id,status,status_code,run_count,creation_time,start_time,update_time,end_time,vendor_type) VALUES (exec_id,job.job_uuid,new_status,status_code,1,job.creation_time,job.update_time,job.update_time,job.update_time,vendor_type);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
/* drop the old notification_job table */
|
/* drop the old notification_job table */
|
||||||
DROP TABLE IF EXISTS notification_job;
|
DROP TABLE IF EXISTS notification_job;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user