feat(worker): add pipeline version upgrade command

This commit is contained in:
kk10
2026-11-16 22:26:35 +03:00
parent 5442dfd3bc
commit f8ca7a7218
6 changed files with 181 additions and 5 deletions
+21
View File
@@ -113,6 +113,14 @@ WHERE id = sqlc.arg(id)::uuid
)
FOR UPDATE;
-- name: LockAttachmentForUpgrade :one
SELECT * FROM attachments
WHERE id = sqlc.arg(id)::uuid
AND pipeline_version = 1
AND status IN ('queued', 'processing')
AND staging_key IS NOT NULL
FOR UPDATE;
-- name: ClearAttachmentStagingKey :exec
UPDATE attachments
SET staging_key = NULL
@@ -160,6 +168,19 @@ WHERE id = sqlc.arg(id)::uuid
AND attempts = sqlc.arg(attempt)::int
AND lease_until > now();
-- name: UpgradeAttachmentPipeline :execrows
UPDATE attachments
SET pipeline_version = 2,
status = 'queued',
retry_base = attempts,
error_code = NULL,
lease_until = NULL,
updated_at = now()
WHERE id = sqlc.arg(id)::uuid
AND pipeline_version = 1
AND status IN ('queued', 'processing')
AND staging_key IS NOT NULL;
-- name: ReplayAttachmentJob :execrows
UPDATE attachments
SET status = 'queued',