Skip to content

Commit 8170c47

Browse files
author
zsbahtiar
committed
feat(DeleteRunByID): add delete action_run_job
1 parent 6c58a02 commit 8170c47

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

models/actions/run.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,22 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
436436

437437
type ActionRunIndex db.ResourceIndex
438438

439-
// DeleteRunByID delete action_run.
439+
// DeleteRunByID delete action_run and action_run_job.
440440
func DeleteRunByID(ctx context.Context, id int64) error {
441-
var run ActionRun
442-
_, err := db.GetEngine(ctx).Where("id=?", id).Delete(&run)
443-
return err
441+
ctx, committer, err := db.TxContext(ctx)
442+
if err != nil {
443+
return err
444+
}
445+
defer committer.Close()
446+
_, err = db.GetEngine(ctx).Where("id=?", id).Delete(ActionRun{})
447+
if err != nil {
448+
return err
449+
}
450+
451+
_, err = db.GetEngine(ctx).Where("run_id=?", id).Delete(ActionRunJob{})
452+
if err != nil {
453+
return err
454+
}
455+
456+
return committer.Commit()
444457
}

0 commit comments

Comments
 (0)