mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
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:
commit
094a4f48ab
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -29,5 +29,6 @@ func init() {
|
||||
new(ScanJob),
|
||||
new(RepoRecord),
|
||||
new(ImgScanOverview),
|
||||
new(ClairVulnTimestamp))
|
||||
new(ClairVulnTimestamp),
|
||||
new(ProjectMetadata))
|
||||
}
|
||||
|
@ -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"`
|
||||
|
Loading…
Reference in New Issue
Block a user