-- Verify document exists at database level (bypassing all RLS and views) -- Step 1: Check if documents is a table or view SELECT table_schema, table_name, table_type FROM information_schema.tables WHERE table_name = 'documents' AND table_schema = 'public'; -- Step 2: Check document with superuser privileges (bypasses everything) -- This will show if document actually exists in base table SET ROLE postgres; SELECT id, user_id, status, original_file_name, created_at FROM public.documents WHERE id = '78359b58-762c-4a68-a8e4-17ce38580a8d'::uuid; -- If no rows returned, document doesn't exist in base table -- If rows returned, document exists but FK constraint still can't see it RESET ROLE; -- Step 3: Check all schemas for documents table SELECT schemaname, tablename, tableowner FROM pg_tables WHERE tablename = 'documents'; -- Step 4: Check if there are any views named documents SELECT schemaname, viewname FROM pg_views WHERE viewname = 'documents'; -- Step 5: Count total documents in base table SET ROLE postgres; SELECT COUNT(*) as total_documents FROM public.documents; SELECT COUNT(*) as processing_llm_documents FROM public.documents WHERE status = 'processing_llm'; RESET ROLE;