diff --git a/make/migrations/postgresql/0010_1.9.0_schema.up.sql b/make/migrations/postgresql/0010_1.9.0_schema.up.sql index f4e0b6519..249bf4878 100644 --- a/make/migrations/postgresql/0010_1.9.0_schema.up.sql +++ b/make/migrations/postgresql/0010_1.9.0_schema.up.sql @@ -118,6 +118,7 @@ create table retention_task ( id SERIAL NOT NULL, execution_id integer, + repository varchar(255), job_id varchar(64), status varchar(32), start_time timestamp default CURRENT_TIMESTAMP, diff --git a/src/pkg/retention/dao/models/retention.go b/src/pkg/retention/dao/models/retention.go index b66ae69b7..b0864a36a 100644 --- a/src/pkg/retention/dao/models/retention.go +++ b/src/pkg/retention/dao/models/retention.go @@ -57,6 +57,7 @@ type RetentionExecution struct { type RetentionTask struct { ID int64 `orm:"pk;auto;column(id)"` ExecutionID int64 `orm:"column(execution_id)"` + Repository string `orm:"column(repository)"` JobID string `orm:"column(job_id)"` Status string `orm:"column(status)"` StartTime time.Time `orm:"column(start_time)"` diff --git a/src/pkg/retention/launcher.go b/src/pkg/retention/launcher.go index 6f2498c8a..4111e4300 100644 --- a/src/pkg/retention/launcher.go +++ b/src/pkg/retention/launcher.go @@ -189,6 +189,7 @@ func (l *launcher) Launch(ply *policy.Metadata, executionID int64, isDryRun bool for repo, p := range repositoryRules { taskID, err := l.retentionMgr.CreateTask(&Task{ ExecutionID: executionID, + Repository: repo.Name, StartTime: now, }) if err != nil { diff --git a/src/pkg/retention/manager.go b/src/pkg/retention/manager.go index 36f8dc2f0..5af100650 100644 --- a/src/pkg/retention/manager.go +++ b/src/pkg/retention/manager.go @@ -169,6 +169,7 @@ func (d *DefaultManager) CreateTask(task *Task) (int64, error) { } t := &models.RetentionTask{ ExecutionID: task.ExecutionID, + Repository: task.Repository, JobID: task.JobID, Status: task.Status, StartTime: task.StartTime, @@ -191,6 +192,7 @@ func (d *DefaultManager) ListTasks(query ...*q.TaskQuery) ([]*Task, error) { tasks = append(tasks, &Task{ ID: t.ID, ExecutionID: t.ExecutionID, + Repository: t.Repository, JobID: t.JobID, Status: t.Status, StartTime: t.StartTime, @@ -211,6 +213,7 @@ func (d *DefaultManager) UpdateTask(task *Task, cols ...string) error { return dao.UpdateTask(&models.RetentionTask{ ID: task.ID, ExecutionID: task.ExecutionID, + Repository: task.Repository, JobID: task.JobID, Status: task.Status, StartTime: task.StartTime, @@ -230,6 +233,7 @@ func (d *DefaultManager) GetTask(taskID int64) (*Task, error) { return &Task{ ID: task.ID, ExecutionID: task.ExecutionID, + Repository: task.Repository, JobID: task.JobID, Status: task.Status, StartTime: task.StartTime, diff --git a/src/pkg/retention/models.go b/src/pkg/retention/models.go index ebbc524ad..63b544aa4 100644 --- a/src/pkg/retention/models.go +++ b/src/pkg/retention/models.go @@ -51,6 +51,7 @@ type Execution struct { type Task struct { ID int64 `json:"id"` ExecutionID int64 `json:"execution_id"` + Repository string `json:"repository"` JobID string `json:"job_id"` Status string `json:"status"` StartTime time.Time `json:"start_time"`