@@ -436,8 +436,8 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
436436
437437type ActionRunIndex db.ResourceIndex
438438
439- // DeleteRunByIDs delete action_run and action_run_job.
440- func DeleteRunByIDs (ctx context.Context , ids []int64 ) error {
439+ // DeleteRunByIDs delete action_task_step, action_task_output, action_task, action_run and action_run_job.
440+ func DeleteRunByIDs (ctx context.Context , runIDs , jobIDs []int64 ) error {
441441 ctx , committer , err := db .TxContext (ctx )
442442 if err != nil {
443443 return err
@@ -447,7 +447,7 @@ func DeleteRunByIDs(ctx context.Context, ids []int64) error {
447447 _ , err = db .GetEngine (ctx ).
448448 Table ("action_task" ).
449449 Join ("INNER" , "action_task_step" , "action_task.id = action_task_step.task_id" ).
450- In ("action_task.job_id" , ids ).
450+ In ("action_task.job_id" , jobIDs ).
451451 Delete (ActionTaskStep {})
452452 if err != nil {
453453 return err
@@ -456,23 +456,23 @@ func DeleteRunByIDs(ctx context.Context, ids []int64) error {
456456 _ , err = db .GetEngine (ctx ).
457457 Table ("action_task" ).
458458 Join ("INNER" , "action_task_output" , "action_task.id = action_task_output.task_id" ).
459- In ("action_task.job_id" , ids ).
459+ In ("action_task.job_id" , jobIDs ).
460460 Delete (ActionTaskOutput {})
461461 if err != nil {
462462 return err
463463 }
464464
465- _ , err = db .GetEngine (ctx ).In ("job_id" , ids ).Delete (ActionTask {})
465+ _ , err = db .GetEngine (ctx ).In ("job_id" , jobIDs ).Delete (ActionTask {})
466466 if err != nil {
467467 return err
468468 }
469469
470- _ , err = db .GetEngine (ctx ).In ("run_id " , ids ).Delete (ActionRunJob {})
470+ _ , err = db .GetEngine (ctx ).In ("id " , jobIDs ).Delete (ActionRunJob {})
471471 if err != nil {
472472 return err
473473 }
474474
475- _ , err = db .GetEngine (ctx ).In ("id" , ids ).Delete (ActionRun {})
475+ _ , err = db .GetEngine (ctx ).In ("id" , runIDs ).Delete (ActionRun {})
476476 if err != nil {
477477 return err
478478 }
0 commit comments