feat(jobs/runners): worktree prune two-phase + workspace prune queries/repo methods

This commit is contained in:
2026-05-06 07:55:56 +08:00
parent 0111135e78
commit c50621eeca
8 changed files with 638 additions and 12 deletions
+32
View File
@@ -49,3 +49,35 @@ RETURNING *;
-- name: DeleteWorktree :exec
DELETE FROM workspace_worktrees WHERE id = $1;
-- name: ListWorktreesNeedingPruneWarning :many
SELECT * FROM workspace_worktrees
WHERE status = 'idle'
AND prune_warning_at IS NULL
AND last_used_at < $1
ORDER BY last_used_at ASC;
-- name: ListWorktreesNeedingPrune :many
SELECT * FROM workspace_worktrees
WHERE status = 'idle'
AND last_used_at < $1
ORDER BY last_used_at ASC;
-- name: MarkPruneWarning :exec
UPDATE workspace_worktrees
SET prune_warning_at = now()
WHERE id = $1 AND prune_warning_at IS NULL;
-- name: TryStartPrune :one
UPDATE workspace_worktrees
SET status = 'pruning'
WHERE id = $1 AND status = 'idle'
RETURNING *;
-- name: FinishPruneSuccess :exec
DELETE FROM workspace_worktrees WHERE id = $1;
-- name: FinishPruneRollback :exec
UPDATE workspace_worktrees
SET status = 'idle'
WHERE id = $1 AND status = 'pruning';