Skip to content

Commit 7f511d9

Browse files
author
zsbahtiar
committed
feat(DeleteRunByIDs): add delete action_task_step, action_task_output, action_task
1 parent 8413beb commit 7f511d9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

models/actions/run.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,26 @@ func DeleteRunByIDs(ctx context.Context, ids []int64) error {
443443
return err
444444
}
445445
defer committer.Close()
446-
_, err = db.GetEngine(ctx).In("id", ids).Delete(ActionRun{})
446+
447+
_, err = db.GetEngine(ctx).
448+
Table("action_task").
449+
Join("INNER", "action_task_step", "action_task.id = action_task_step.task_id").
450+
In("action_task.job_id", ids).
451+
Delete(ActionTaskStep{})
452+
if err != nil {
453+
return err
454+
}
455+
456+
_, err = db.GetEngine(ctx).
457+
Table("action_task").
458+
Join("INNER", "action_task_output", "action_task.id = action_task_output.task_id").
459+
In("action_task.job_id", ids).
460+
Delete(ActionTaskOutput{})
461+
if err != nil {
462+
return err
463+
}
464+
465+
_, err = db.GetEngine(ctx).In("job_id", ids).Delete(ActionTask{})
447466
if err != nil {
448467
return err
449468
}
@@ -453,6 +472,11 @@ func DeleteRunByIDs(ctx context.Context, ids []int64) error {
453472
return err
454473
}
455474

475+
_, err = db.GetEngine(ctx).In("id", ids).Delete(ActionRun{})
476+
if err != nil {
477+
return err
478+
}
479+
456480
return committer.Commit()
457481
}
458482

0 commit comments

Comments
 (0)