mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-30 06:03:45 +01:00
f160505686
1, move the deleted artifact into trash 2, disable GC to delete the untagged manifest Signed-off-by: wang yan <wangyan@vmware.com>
72 lines
2.6 KiB
SQL
72 lines
2.6 KiB
SQL
/* TODO remove the table artifact_2 and use the artifact instead after finishing the upgrade work */
|
|
CREATE TABLE artifact_2
|
|
(
|
|
id SERIAL PRIMARY KEY NOT NULL,
|
|
/* image, chart, etc */
|
|
type varchar(255) NOT NULL,
|
|
media_type varchar(255) NOT NULL,
|
|
manifest_media_type varchar(255) NOT NULL,
|
|
project_id int NOT NULL,
|
|
repository_id int NOT NULL,
|
|
digest varchar(255) NOT NULL,
|
|
size bigint,
|
|
push_time timestamp default CURRENT_TIMESTAMP,
|
|
pull_time timestamp,
|
|
extra_attrs text,
|
|
annotations jsonb,
|
|
CONSTRAINT unique_artifact_2 UNIQUE (repository_id, digest)
|
|
);
|
|
|
|
CREATE TABLE tag
|
|
(
|
|
id SERIAL PRIMARY KEY NOT NULL,
|
|
repository_id int NOT NULL,
|
|
artifact_id int NOT NULL,
|
|
name varchar(255) NOT NULL,
|
|
push_time timestamp default CURRENT_TIMESTAMP,
|
|
pull_time timestamp,
|
|
/* TODO replace artifact_2 after finishing the upgrade work */
|
|
FOREIGN KEY (artifact_id) REFERENCES artifact_2(id),
|
|
CONSTRAINT unique_tag UNIQUE (repository_id, name)
|
|
);
|
|
|
|
/* artifact_reference records the child artifact referenced by parent artifact */
|
|
CREATE TABLE artifact_reference
|
|
(
|
|
id SERIAL PRIMARY KEY NOT NULL,
|
|
parent_id int NOT NULL,
|
|
child_id int NOT NULL,
|
|
platform varchar(255),
|
|
/* TODO replace artifact_2 after finishing the upgrade work */
|
|
FOREIGN KEY (parent_id) REFERENCES artifact_2(id),
|
|
FOREIGN KEY (child_id) REFERENCES artifact_2(id),
|
|
CONSTRAINT unique_reference UNIQUE (parent_id, child_id)
|
|
);
|
|
|
|
/* artifact_trash records deleted artifact */
|
|
CREATE TABLE artifact_trash
|
|
(
|
|
id SERIAL PRIMARY KEY NOT NULL,
|
|
media_type varchar(255) NOT NULL,
|
|
manifest_media_type varchar(255) NOT NULL,
|
|
repository_name varchar(255) NOT NULL,
|
|
digest varchar(255) NOT NULL,
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
CONSTRAINT unique_artifact_trash UNIQUE (repository_name, digest)
|
|
);
|
|
|
|
/* TODO upgrade: how about keep the table "harbor_resource_label" only for helm v2 chart and use the new table for artifact label reference? */
|
|
/* label_reference records the labels added to the artifact */
|
|
CREATE TABLE label_reference (
|
|
id SERIAL PRIMARY KEY NOT NULL,
|
|
label_id int NOT NULL,
|
|
artifact_id int NOT NULL,
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (label_id) REFERENCES harbor_label(id),
|
|
/* TODO replace artifact_2 after finishing the upgrade work */
|
|
FOREIGN KEY (artifact_id) REFERENCES artifact_2(id),
|
|
CONSTRAINT unique_label_reference UNIQUE (label_id,artifact_id)
|
|
);
|
|
|