Merge pull request #3490 from ywk253100/171030_meta_id

Add column id to table project_metadagta as the primary key
This commit is contained in:
Wenkai Yin 2017-10-31 00:42:04 -05:00 committed by GitHub
commit 094a4f48ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 9 deletions

View File

@ -97,18 +97,20 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim
(1, 1, 1, NOW(), NOW());
create table project_metadata (
id int NOT NULL AUTO_INCREMENT,
project_id int NOT NULL,
name varchar(255) NOT NULL,
value varchar(255),
creation_time timestamp default CURRENT_TIMESTAMP,
update_time timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
deleted tinyint (1) DEFAULT 0 NOT NULL,
PRIMARY KEY (project_id, name),
PRIMARY KEY (id),
CONSTRAINT unique_project_id_and_name UNIQUE (project_id,name),
FOREIGN KEY (project_id) REFERENCES project(project_id)
);
insert into project_metadata (project_id, name, value, creation_time, update_time, deleted) values
(1, 'public', 'true', NOW(), NOW(), 0);
insert into project_metadata (id, project_id, name, value, creation_time, update_time, deleted) values
(1, 1, 'public', 'true', NOW(), NOW(), 0);
create table access_log (
log_id int NOT NULL AUTO_INCREMENT,

View File

@ -94,18 +94,19 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim
(1, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
create table project_metadata (
id INTEGER PRIMARY KEY,
project_id int NOT NULL,
name varchar(255) NOT NULL,
value varchar(255),
creation_time timestamp,
update_time timestamp,
deleted tinyint (1) DEFAULT 0 NOT NULL,
PRIMARY KEY (project_id, name),
UNIQUE(project_id, name) ON CONFLICT REPLACE,
FOREIGN KEY (project_id) REFERENCES project(project_id)
);
insert into project_metadata (project_id, name, value, creation_time, update_time, deleted) values
(1, 'public', 'true', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0);
insert into project_metadata (id, project_id, name, value, creation_time, update_time, deleted) values
(1, 1, 'public', 'true', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0);
create table access_log (
log_id INTEGER PRIMARY KEY,

View File

@ -22,8 +22,6 @@ import (
"github.com/vmware/harbor/src/common/models"
)
// Using raw sql instead of CRUD objects as beego does not support composite primary key
// AddProjectMetadata adds metadata for a project
func AddProjectMetadata(meta *models.ProjectMetadata) error {
now := time.Now()

View File

@ -29,5 +29,6 @@ func init() {
new(ScanJob),
new(RepoRecord),
new(ImgScanOverview),
new(ClairVulnTimestamp))
new(ClairVulnTimestamp),
new(ProjectMetadata))
}

View File

@ -33,6 +33,7 @@ const (
// ProjectMetadata holds the metadata of a project.
type ProjectMetadata struct {
ID int64 `orm:"pk;auto;column(id)" json:"id"`
ProjectID int64 `orm:"column(project_id)" json:"project_id"`
Name string `orm:"column(name)" json:"name"`
Value string `orm:"column(value)" json:"value"`