From 389a8c49f460488ddbbf2dcd5ba20fe6a6f0bd4e Mon Sep 17 00:00:00 2001 From: MinerYang Date: Mon, 8 Apr 2024 14:25:19 +0800 Subject: [PATCH] update artifact_type column alteration (#20239) update column if is null Signed-off-by: yminer Co-authored-by: Wang Yan --- make/migrations/postgresql/0140_2.11.0_schema.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/migrations/postgresql/0140_2.11.0_schema.up.sql b/make/migrations/postgresql/0140_2.11.0_schema.up.sql index b43f6072f..fd6fb16ed 100644 --- a/make/migrations/postgresql/0140_2.11.0_schema.up.sql +++ b/make/migrations/postgresql/0140_2.11.0_schema.up.sql @@ -20,12 +20,12 @@ table artifact: /* Add new column artifact_type for artifact table to work with oci-spec v1.1.0 list referrer api */ -ALTER TABLE artifact ADD COLUMN artifact_type varchar(255); +ALTER TABLE artifact ADD COLUMN IF NOT EXISTS artifact_type varchar(255); /* set value for artifact_type then set column artifact_type as not null */ -UPDATE artifact SET artifact_type = media_type; +UPDATE artifact SET artifact_type = media_type WHERE artifact_type IS NULL; ALTER TABLE artifact ALTER COLUMN artifact_type SET NOT NULL; \ No newline at end of file