diff options
Diffstat (limited to 'makima/src/db/repository.rs')
| -rw-r--r-- | makima/src/db/repository.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index e288eba..d8168f6 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -5465,6 +5465,25 @@ pub async fn delete_directive_step( Ok(result.rows_affected() > 0) } +/// Delete all directive steps that have not started execution (pending, ready, failed, skipped). +/// Completed and running steps are preserved. +/// Returns the number of deleted steps. +pub async fn clear_pending_directive_steps( + pool: &PgPool, + directive_id: Uuid, +) -> Result<u64, sqlx::Error> { + let result = sqlx::query( + r#"DELETE FROM directive_steps + WHERE directive_id = $1 + AND status IN ('pending', 'ready', 'failed', 'skipped')"#, + ) + .bind(directive_id) + .execute(pool) + .await?; + + Ok(result.rows_affected()) +} + // ============================================================================= // Directive DAG Progression // ============================================================================= |
