-- name: CreateProcessingJob :one
INSERT INTO processing_jobs (
  file_id
) VALUES ($1)
RETURNING *;

-- name: StartProcessingJob :exec
UPDATE processing_jobs 
SET started = NOW(),
  status = 'started'
WHERE id = $1;

-- name: FinishProcessingJob :exec
UPDATE processing_jobs
SET completed = NOW(),
  status = 'completed'
WHERE id = $1;

-- name: GetJobsForFile :many
SELECT * FROM processing_jobs
WHERE file_id = $1;

-- name: GetJob :one
SELECT * FROM processing_jobs
WHERE id = $1
LIMIT 1;

-- name: FailProcessingJob :exec
UPDATE processing_jobs
SET completed = NOW(),
  status = 'failed',
  error = $1
WHERE id = $2;

