From 84094e7a5d127beec895e8ea3ac25b8f70a627df Mon Sep 17 00:00:00 2001 From: wang yan Date: Thu, 27 Aug 2020 17:11:53 +0800 Subject: [PATCH] fix migration issue fixes #12889 Before the migration script to fix the nativate repo_id issue, is has to remove the duplicate tags from the tag table, which may caused by user in v2.0.2 to retag & repush the missing image. Signed-off-by: wang yan --- make/migrations/postgresql/0031_2.0.3_schema.up.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/make/migrations/postgresql/0031_2.0.3_schema.up.sql b/make/migrations/postgresql/0031_2.0.3_schema.up.sql index fe598ff18..cc82b8b3c 100644 --- a/make/migrations/postgresql/0031_2.0.3_schema.up.sql +++ b/make/migrations/postgresql/0031_2.0.3_schema.up.sql @@ -9,6 +9,13 @@ Fixes https://github.com/goharbor/harbor/issues/12827 resolve it. */ +/* Delete the duplicate tags if user re-tag & re-push the missing images */ +DELETE FROM tag +WHERE id NOT IN + (SELECT MAX(id) AS id + FROM (SELECT t.*, art.repository_name FROM artifact AS art JOIN tag AS t ON art.id = t.artifact_id) t1 + GROUP BY t1.name, t1.repository_name); + /* Insert the missing repository records */ INSERT INTO repository (name, project_id) SELECT DISTINCT repository_name, project_id FROM artifact WHERE repository_id<0 AND