-- Check RLS status and policies on documents table
SELECT 
  tablename,
  rowsecurity as rls_enabled
FROM pg_tables 
WHERE schemaname = 'public' 
  AND tablename IN ('documents', 'processing_jobs');

-- Check RLS policies on documents
SELECT 
  schemaname,
  tablename,
  policyname,
  permissive,
  roles,
  cmd,
  qual,
  with_check
FROM pg_policies
WHERE tablename IN ('documents', 'processing_jobs')
ORDER BY tablename, policyname;

-- Check current role
SELECT current_user, current_role, session_user;

