2016-02-01 12:59:10 +01:00
|
|
|
create table access (
|
2018-06-01 08:58:43 +02:00
|
|
|
access_id SERIAL PRIMARY KEY NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
access_code char(1),
|
2018-06-01 08:58:43 +02:00
|
|
|
comment varchar (30)
|
2016-02-01 12:59:10 +01:00
|
|
|
);
|
|
|
|
|
2016-03-25 10:42:58 +01:00
|
|
|
insert into access (access_code, comment) values
|
|
|
|
('M', 'Management access for project'),
|
|
|
|
('R', 'Read access for project'),
|
|
|
|
('W', 'Write access for project'),
|
|
|
|
('D', 'Delete access for project'),
|
|
|
|
('S', 'Search access for project');
|
2016-02-01 12:59:10 +01:00
|
|
|
|
|
|
|
create table role (
|
2018-06-01 08:58:43 +02:00
|
|
|
role_id SERIAL PRIMARY KEY NOT NULL,
|
2016-03-25 09:58:20 +01:00
|
|
|
role_mask int DEFAULT 0 NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
role_code varchar(20),
|
2018-06-01 08:58:43 +02:00
|
|
|
name varchar (20)
|
2016-02-01 12:59:10 +01:00
|
|
|
);
|
2018-06-01 08:58:43 +02:00
|
|
|
|
2016-03-25 09:58:20 +01:00
|
|
|
/*
|
|
|
|
role mask is used for future enhancement when a project member can have multi-roles
|
|
|
|
currently set to 0
|
|
|
|
*/
|
2016-02-01 12:59:10 +01:00
|
|
|
|
2016-03-25 10:42:58 +01:00
|
|
|
insert into role (role_code, name) values
|
|
|
|
('MDRWS', 'projectAdmin'),
|
|
|
|
('RWS', 'developer'),
|
|
|
|
('RS', 'guest');
|
2016-02-01 12:59:10 +01:00
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
create table harbor_user (
|
|
|
|
user_id SERIAL PRIMARY KEY NOT NULL,
|
2017-08-17 07:09:33 +02:00
|
|
|
username varchar(255),
|
2016-08-19 08:59:46 +02:00
|
|
|
email varchar(255),
|
2016-02-01 12:59:10 +01:00
|
|
|
password varchar(40) NOT NULL,
|
2017-06-19 18:19:30 +02:00
|
|
|
realname varchar (255) NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
comment varchar (30),
|
2018-06-01 08:58:43 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
reset_uuid varchar(40) DEFAULT NULL,
|
|
|
|
salt varchar(40) DEFAULT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
sysadmin_flag boolean DEFAULT false NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2016-02-01 12:59:10 +01:00
|
|
|
UNIQUE (username),
|
|
|
|
UNIQUE (email)
|
|
|
|
);
|
|
|
|
|
2018-07-30 12:05:50 +02:00
|
|
|
CREATE FUNCTION update_update_time_at_column() RETURNS trigger
|
|
|
|
LANGUAGE plpgsql
|
|
|
|
AS $$
|
|
|
|
BEGIN
|
|
|
|
NEW.update_time = NOW();
|
|
|
|
RETURN NEW;
|
|
|
|
END;
|
|
|
|
$$;
|
|
|
|
|
|
|
|
CREATE TRIGGER harbor_user_update_time_at_modtime BEFORE UPDATE ON harbor_user FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
insert into harbor_user (username, email, password, realname, comment, deleted, sysadmin_flag, creation_time, update_time) values
|
|
|
|
('admin', 'admin@example.com', '', 'system admin', 'admin user',false, true, NOW(), NOW()),
|
|
|
|
('anonymous', 'anonymous@example.com', '', 'anonymous user', 'anonymous user', true, false, NOW(), NOW());
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
create table project (
|
2018-06-01 08:58:43 +02:00
|
|
|
project_id SERIAL PRIMARY KEY NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
owner_id int NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
The max length of name controlled by API is 30,
|
|
|
|
and 11 is reserved for marking the deleted project.
|
|
|
|
*/
|
2018-01-16 08:38:05 +01:00
|
|
|
name varchar (255) NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
|
|
|
FOREIGN KEY (owner_id) REFERENCES harbor_user(user_id),
|
2016-02-17 07:29:05 +01:00
|
|
|
UNIQUE (name)
|
2016-02-01 12:59:10 +01:00
|
|
|
);
|
|
|
|
|
2018-07-30 12:05:50 +02:00
|
|
|
CREATE TRIGGER project_update_time_at_modtime BEFORE UPDATE ON project FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2017-09-29 10:37:43 +02:00
|
|
|
insert into project (owner_id, name, creation_time, update_time) values
|
|
|
|
(1, 'library', NOW(), NOW());
|
2016-02-01 12:59:10 +01:00
|
|
|
|
2016-03-25 09:58:20 +01:00
|
|
|
create table project_member (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
project_id int NOT NULL,
|
2018-02-06 03:59:49 +01:00
|
|
|
entity_id int NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
entity_type indicates the type of member,
|
|
|
|
u for user, g for user group
|
|
|
|
*/
|
|
|
|
entity_type char(1) NOT NULL,
|
2016-03-25 09:58:20 +01:00
|
|
|
role int NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-02-06 03:59:49 +01:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
CONSTRAINT unique_project_entity_type UNIQUE (project_id, entity_id, entity_type)
|
2018-06-01 08:58:43 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TRIGGER project_member_update_time_at_modtime BEFORE UPDATE ON project_member FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2016-02-01 12:59:10 +01:00
|
|
|
|
2018-02-06 03:59:49 +01:00
|
|
|
insert into project_member (project_id, entity_id, role, entity_type) values
|
|
|
|
(1, 1, 1, 'u');
|
2016-02-01 12:59:10 +01:00
|
|
|
|
2017-09-28 07:52:53 +02:00
|
|
|
create table project_metadata (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2017-09-28 07:52:53 +02:00
|
|
|
project_id int NOT NULL,
|
|
|
|
name varchar(255) NOT NULL,
|
|
|
|
value varchar(255),
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
2017-10-30 10:03:28 +01:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
CONSTRAINT unique_project_id_and_name UNIQUE (project_id,name),
|
2017-09-28 07:52:53 +02:00
|
|
|
FOREIGN KEY (project_id) REFERENCES project(project_id)
|
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER project_metadata_update_time_at_modtime BEFORE UPDATE ON project_metadata FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2018-02-06 03:59:49 +01:00
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
insert into project_metadata (project_id, name, value, creation_time, update_time, deleted) values
|
|
|
|
(1, 'public', 'true', NOW(), NOW(), false);
|
2018-02-06 03:59:49 +01:00
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
create table user_group (
|
|
|
|
id SERIAL NOT NULL,
|
|
|
|
group_name varchar(255) NOT NULL,
|
|
|
|
group_type smallint default 0,
|
|
|
|
ldap_group_dn varchar(512) NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
PRIMARY KEY (id)
|
2018-02-06 03:59:49 +01:00
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER user_group_update_time_at_modtime BEFORE UPDATE ON user_group FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
create table access_log (
|
2018-06-01 08:58:43 +02:00
|
|
|
log_id SERIAL NOT NULL,
|
2017-08-17 07:09:33 +02:00
|
|
|
username varchar (255) NOT NULL,
|
2016-02-01 12:59:10 +01:00
|
|
|
project_id int NOT NULL,
|
2016-06-22 06:22:02 +02:00
|
|
|
repo_name varchar (256),
|
|
|
|
repo_tag varchar (128),
|
2016-02-01 12:59:10 +01:00
|
|
|
GUID varchar(64),
|
|
|
|
operation varchar(20) NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
op_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
primary key (log_id)
|
2016-02-01 12:59:10 +01:00
|
|
|
);
|
2016-04-07 10:49:11 +02:00
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE INDEX pid_optime ON access_log (project_id, op_time);
|
|
|
|
|
2016-08-29 15:21:49 +02:00
|
|
|
create table repository (
|
2018-06-01 08:58:43 +02:00
|
|
|
repository_id SERIAL NOT NULL,
|
2016-08-29 15:21:49 +02:00
|
|
|
name varchar(255) NOT NULL,
|
|
|
|
project_id int NOT NULL,
|
|
|
|
description text,
|
|
|
|
pull_count int DEFAULT 0 NOT NULL,
|
|
|
|
star_count int DEFAULT 0 NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2016-08-29 15:21:49 +02:00
|
|
|
primary key (repository_id),
|
|
|
|
UNIQUE (name)
|
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER repository_update_time_at_modtime BEFORE UPDATE ON repository FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2016-05-10 13:38:50 +02:00
|
|
|
create table replication_policy (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2016-05-10 13:38:50 +02:00
|
|
|
name varchar(256),
|
|
|
|
project_id int NOT NULL,
|
|
|
|
target_id int NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
enabled boolean NOT NULL DEFAULT true,
|
2016-05-10 13:38:50 +02:00
|
|
|
description text,
|
2018-06-01 08:58:43 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
2016-04-20 08:24:17 +02:00
|
|
|
cron_str varchar(256),
|
2017-11-02 05:53:01 +01:00
|
|
|
filters varchar(1024),
|
2018-06-01 08:58:43 +02:00
|
|
|
replicate_deletion boolean DEFAULT false NOT NULL,
|
2016-06-01 07:28:02 +02:00
|
|
|
start_time timestamp NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2016-05-10 13:38:50 +02:00
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER replication_policy_update_time_at_modtime BEFORE UPDATE ON replication_policy FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2016-05-10 13:38:50 +02:00
|
|
|
create table replication_target (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2016-05-10 13:38:50 +02:00
|
|
|
name varchar(64),
|
|
|
|
url varchar(64),
|
2017-08-17 07:09:33 +02:00
|
|
|
username varchar(255),
|
2016-08-03 11:25:24 +02:00
|
|
|
password varchar(128),
|
2016-06-17 12:54:29 +02:00
|
|
|
/*
|
|
|
|
target_type indicates the type of target registry,
|
|
|
|
0 means it's a harbor instance,
|
|
|
|
1 means it's a regulart registry
|
|
|
|
*/
|
2018-06-01 08:58:43 +02:00
|
|
|
target_type SMALLINT NOT NULL DEFAULT 0,
|
|
|
|
insecure boolean NOT NULL DEFAULT false,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2016-05-10 13:38:50 +02:00
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
2018-06-01 08:58:43 +02:00
|
|
|
|
|
|
|
CREATE TRIGGER replication_target_update_time_at_modtime BEFORE UPDATE ON replication_target FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2016-05-10 13:38:50 +02:00
|
|
|
|
|
|
|
create table replication_job (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2016-05-10 13:38:50 +02:00
|
|
|
status varchar(64) NOT NULL,
|
|
|
|
policy_id int NOT NULL,
|
|
|
|
repository varchar(256) NOT NULL,
|
|
|
|
operation varchar(64) NOT NULL,
|
2016-05-25 10:33:45 +02:00
|
|
|
tags varchar(16384),
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
New job service only records uuid, for compatibility in this table both IDs are stored.
|
|
|
|
*/
|
2018-03-23 10:45:50 +01:00
|
|
|
job_uuid varchar(64),
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
PRIMARY KEY (id)
|
2016-05-10 13:38:50 +02:00
|
|
|
);
|
2018-06-01 08:58:43 +02:00
|
|
|
|
|
|
|
CREATE INDEX policy ON replication_job (policy_id);
|
|
|
|
CREATE INDEX poid_uptime ON replication_job (policy_id, update_time);
|
|
|
|
CREATE INDEX poid_status ON replication_job (policy_id, status);
|
|
|
|
|
|
|
|
CREATE TRIGGER replication_job_update_time_at_modtime BEFORE UPDATE ON replication_job FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2017-11-21 06:08:09 +01:00
|
|
|
|
|
|
|
create table replication_immediate_trigger (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2017-11-21 06:08:09 +01:00
|
|
|
policy_id int NOT NULL,
|
|
|
|
namespace varchar(256) NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
on_push boolean NOT NULL DEFAULT false,
|
|
|
|
on_deletion boolean NOT NULL DEFAULT false,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2017-11-21 06:08:09 +01:00
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
2016-04-20 08:24:17 +02:00
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER replication_immediate_trigger_update_time_at_modtime BEFORE UPDATE ON replication_immediate_trigger FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
|
|
|
create table img_scan_job (
|
|
|
|
id SERIAL NOT NULL,
|
2017-05-11 15:41:57 +02:00
|
|
|
status varchar(64) NOT NULL,
|
|
|
|
repository varchar(256) NOT NULL,
|
2018-03-21 09:19:54 +01:00
|
|
|
tag varchar(128) NOT NULL,
|
2017-06-08 09:04:23 +02:00
|
|
|
digest varchar(128),
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
New job service only records uuid, for compatibility in this table both IDs are stored.
|
|
|
|
*/
|
2018-03-23 10:45:50 +01:00
|
|
|
job_uuid varchar(64),
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-01 08:58:43 +02:00
|
|
|
PRIMARY KEY (id)
|
2017-05-11 15:41:57 +02:00
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE INDEX idx_status ON img_scan_job (status);
|
|
|
|
CREATE INDEX idx_digest ON img_scan_job (digest);
|
|
|
|
CREATE INDEX idx_uuid ON img_scan_job (job_uuid);
|
|
|
|
CREATE INDEX idx_repository_tag ON img_scan_job (repository,tag);
|
|
|
|
|
|
|
|
CREATE TRIGGER img_scan_job_update_time_at_modtime BEFORE UPDATE ON img_scan_job FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2017-06-13 15:46:52 +02:00
|
|
|
create table img_scan_overview (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2017-06-13 15:46:52 +02:00
|
|
|
image_digest varchar(128) NOT NULL,
|
|
|
|
scan_job_id int NOT NULL,
|
|
|
|
/* 0 indicates none, the higher the number, the more severe the status */
|
|
|
|
severity int NOT NULL default 0,
|
|
|
|
/* the json string to store components severity status, currently use a json to be more flexible and avoid creating additional tables. */
|
|
|
|
components_overview varchar(2048),
|
|
|
|
/* primary key for querying details, in clair it should be the name of the "top layer" */
|
|
|
|
details_key varchar(128),
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2017-07-09 06:37:08 +02:00
|
|
|
PRIMARY KEY(id),
|
|
|
|
UNIQUE(image_digest)
|
2017-06-13 15:46:52 +02:00
|
|
|
);
|
2018-06-01 08:58:43 +02:00
|
|
|
|
|
|
|
CREATE TRIGGER img_scan_overview_update_time_at_modtime BEFORE UPDATE ON img_scan_overview FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2017-06-13 15:46:52 +02:00
|
|
|
|
2017-07-04 06:12:16 +02:00
|
|
|
create table clair_vuln_timestamp (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2017-07-04 06:12:16 +02:00
|
|
|
namespace varchar(128) NOT NULL,
|
|
|
|
last_update timestamp NOT NULL,
|
|
|
|
PRIMARY KEY(id),
|
|
|
|
UNIQUE(namespace)
|
|
|
|
);
|
|
|
|
|
2016-04-07 10:49:11 +02:00
|
|
|
create table properties (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2016-04-07 10:49:11 +02:00
|
|
|
k varchar(64) NOT NULL,
|
|
|
|
v varchar(128) NOT NULL,
|
2017-11-15 07:49:14 +01:00
|
|
|
PRIMARY KEY(id),
|
|
|
|
UNIQUE (k)
|
2016-04-07 10:49:11 +02:00
|
|
|
);
|
|
|
|
|
2018-03-07 06:20:28 +01:00
|
|
|
create table harbor_label (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2018-03-07 06:20:28 +01:00
|
|
|
name varchar(128) NOT NULL,
|
|
|
|
description text,
|
|
|
|
color varchar(16),
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
's' for system level labels
|
|
|
|
'u' for user level labels
|
|
|
|
*/
|
2018-03-07 06:20:28 +01:00
|
|
|
level char(1) NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
'g' for global labels
|
|
|
|
'p' for project labels
|
|
|
|
*/
|
2018-03-07 06:20:28 +01:00
|
|
|
scope char(1) NOT NULL,
|
|
|
|
project_id int,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-06-07 10:05:50 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
2018-03-07 06:20:28 +01:00
|
|
|
PRIMARY KEY(id),
|
2017-12-19 15:15:56 +01:00
|
|
|
CONSTRAINT unique_label UNIQUE (name,scope, project_id)
|
2018-03-07 06:20:28 +01:00
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER harbor_label_update_time_at_modtime BEFORE UPDATE ON harbor_label FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
2018-03-12 10:13:01 +01:00
|
|
|
create table harbor_resource_label (
|
2018-06-01 08:58:43 +02:00
|
|
|
id SERIAL NOT NULL,
|
2018-03-12 10:13:01 +01:00
|
|
|
label_id int NOT NULL,
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
the resource_id is the ID of project when the resource_type is p
|
|
|
|
the resource_id is the ID of repository when the resource_type is r
|
|
|
|
*/
|
2018-03-15 09:56:43 +01:00
|
|
|
resource_id int,
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
the resource_name is the name of image when the resource_type is i
|
|
|
|
*/
|
2018-03-15 09:56:43 +01:00
|
|
|
resource_name varchar(256),
|
2018-06-01 08:58:43 +02:00
|
|
|
/*
|
|
|
|
'p' for project
|
|
|
|
'r' for repository
|
|
|
|
'i' for image
|
|
|
|
*/
|
2018-03-12 10:13:01 +01:00
|
|
|
resource_type char(1) NOT NULL,
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-03-12 10:13:01 +01:00
|
|
|
PRIMARY KEY(id),
|
2018-03-21 09:24:21 +01:00
|
|
|
CONSTRAINT unique_label_resource UNIQUE (label_id,resource_id, resource_name, resource_type)
|
2018-03-12 10:13:01 +01:00
|
|
|
);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TRIGGER harbor_resource_label_update_time_at_modtime BEFORE UPDATE ON harbor_resource_label FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
2018-07-20 13:22:37 +02:00
|
|
|
|
|
|
|
create table admin_job (
|
|
|
|
id SERIAL NOT NULL,
|
|
|
|
job_name varchar(64) NOT NULL,
|
|
|
|
job_kind varchar(64) NOT NULL,
|
|
|
|
cron_str varchar(256),
|
|
|
|
status varchar(64) NOT NULL,
|
|
|
|
job_uuid varchar(64),
|
2018-07-30 12:05:50 +02:00
|
|
|
creation_time timestamp default CURRENT_TIMESTAMP,
|
|
|
|
update_time timestamp default CURRENT_TIMESTAMP,
|
2018-07-20 13:22:37 +02:00
|
|
|
deleted boolean DEFAULT false NOT NULL,
|
|
|
|
PRIMARY KEY(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TRIGGER admin_job_update_time_at_modtime BEFORE UPDATE ON admin_job FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();
|
|
|
|
|
|
|
|
CREATE INDEX admin_job_status ON admin_job (status);
|
|
|
|
CREATE INDEX admin_job_uuid ON admin_job (job_uuid);
|
|
|
|
|
2018-06-01 08:58:43 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS alembic_version (
|
|
|
|
version_num varchar(32) NOT NULL
|
|
|
|
);
|
2016-05-09 08:11:34 +02:00
|
|
|
|
2018-07-02 15:23:47 +02:00
|
|
|
insert into alembic_version values ('1.6.0');
|
2018-06-01 08:58:43 +02:00
|
|
|
|