-- Context belongs to the durable job, not the lifetime of the HTTP process. ALTER TABLE attachment_jobs ADD COLUMN traceparent text, ADD COLUMN tracestate text, ADD COLUMN ready_at timestamptz; -- Existing completed jobs predate instrumentation; preserve their actual update time. UPDATE attachment_jobs j SET ready_at=a.updated_at FROM attachments a WHERE a.id=j.attachment_id AND a.status='ready'; CREATE INDEX attachment_jobs_created_idx ON attachment_jobs(created_at);