-- Create job for processing document
-- This bypasses RLS by using service role or direct insert
-- The document ID and user_id are from Supabase client query

-- Option 1: If RLS is blocking, disable it temporarily (run as superuser)
SET ROLE postgres;

-- Create job directly (use the exact IDs from Supabase client)
INSERT INTO processing_jobs (
  document_id,
  user_id,
  status,
  attempts,
  max_attempts,
  options,
  created_at
) VALUES (
  '78359b58-762c-4a68-a8e4-17ce38580a8d'::uuid,  -- Document ID from Supabase client
  'B00HiMnleGhGdJgQwbX2Ume01Z53',                 -- User ID from Supabase client
  'pending',
  0,
  3,
  '{"strategy": "document_ai_agentic_rag"}'::jsonb,
  NOW()
)
ON CONFLICT DO NOTHING  -- In case job already exists
RETURNING id, document_id, status, created_at;

-- Reset role
RESET ROLE;

-- Verify job was created
SELECT 
  pj.id as job_id,
  pj.document_id,
  pj.status as job_status,
  pj.created_at
FROM processing_jobs pj
WHERE pj.document_id = '78359b58-762c-4a68-a8e4-17ce38580a8d'::uuid
ORDER BY pj.created_at DESC;

