mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-21 23:21:26 +01:00
Hard delete project metadata (#8856)
Hard delete project metadata Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
9a4627c583
commit
5da4286ef4
@ -183,4 +183,6 @@ create table notification_policy (
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE replication_task ADD COLUMN status_revision int DEFAULT 0;
|
||||
ALTER TABLE replication_task ADD COLUMN status_revision int DEFAULT 0;
|
||||
DELETE FROM project_metadata WHERE deleted = TRUE;
|
||||
ALTER TABLE project_metadata DROP COLUMN deleted;
|
@ -26,8 +26,8 @@ import (
|
||||
func AddProjectMetadata(meta *models.ProjectMetadata) error {
|
||||
now := time.Now()
|
||||
sql := `insert into project_metadata
|
||||
(project_id, name, value, creation_time, update_time, deleted)
|
||||
values (?, ?, ?, ?, ?, false)`
|
||||
(project_id, name, value, creation_time, update_time)
|
||||
values (?, ?, ?, ?, ?)`
|
||||
_, err := GetOrmer().Raw(sql, meta.ProjectID, meta.Name, meta.Value,
|
||||
now, now).Exec()
|
||||
return err
|
||||
@ -38,8 +38,7 @@ func AddProjectMetadata(meta *models.ProjectMetadata) error {
|
||||
// by name will be deleted
|
||||
func DeleteProjectMetadata(projectID int64, name ...string) error {
|
||||
params := make([]interface{}, 1)
|
||||
sql := `update project_metadata
|
||||
set deleted = true
|
||||
sql := `delete from project_metadata
|
||||
where project_id = ?`
|
||||
params = append(params, projectID)
|
||||
|
||||
@ -56,7 +55,7 @@ func DeleteProjectMetadata(projectID int64, name ...string) error {
|
||||
func UpdateProjectMetadata(meta *models.ProjectMetadata) error {
|
||||
sql := `update project_metadata
|
||||
set value = ?, update_time = ?
|
||||
where project_id = ? and name = ? and deleted = false`
|
||||
where project_id = ? and name = ?`
|
||||
_, err := GetOrmer().Raw(sql, meta.Value, time.Now(), meta.ProjectID,
|
||||
meta.Name).Exec()
|
||||
return err
|
||||
@ -70,7 +69,7 @@ func GetProjectMetadata(projectID int64, name ...string) ([]*models.ProjectMetad
|
||||
params := make([]interface{}, 1)
|
||||
|
||||
sql := `select * from project_metadata
|
||||
where project_id = ? and deleted = false`
|
||||
where project_id = ? `
|
||||
params = append(params, projectID)
|
||||
|
||||
if len(name) > 0 {
|
||||
@ -95,7 +94,7 @@ func ParamPlaceholderForIn(n int) string {
|
||||
// ListProjectMetadata ...
|
||||
func ListProjectMetadata(name, value string) ([]*models.ProjectMetadata, error) {
|
||||
sql := `select * from project_metadata
|
||||
where name = ? and value = ? and deleted = false`
|
||||
where name = ? and value = ? `
|
||||
metadatas := []*models.ProjectMetadata{}
|
||||
_, err := GetOrmer().Raw(sql, name, value).QueryRows(&metadatas)
|
||||
return metadatas, err
|
||||
|
Loading…
Reference in New Issue
Block a user