feat(worker): add pipeline version upgrade command
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user