diff --git a/supabase/migrations/20260807002000_reporting_view_fixes.sql b/supabase/migrations/20260807002000_reporting_view_fixes.sql index 2d12ee4..6211f86 100644 --- a/supabase/migrations/20260807002000_reporting_view_fixes.sql +++ b/supabase/migrations/20260807002000_reporting_view_fixes.sql @@ -62,7 +62,12 @@ SELECT AS payment_plan_balance_cents, COUNT(DISTINCT d.student_id) FILTER (WHERE d.is_past_due) AS delinquent_accounts, CASE - WHEN public.is_billing_admin() OR public.is_auditor() THEN + -- Everyone who can genuinely read public.scholarships: billing admins and + -- auditors by policy, plus service_role (and superusers) by RLS bypass — + -- without that last arm, server-side reporting would see NULL too. + WHEN public.is_billing_admin() + OR public.is_auditor() + OR pg_has_role(current_user, 'service_role', 'MEMBER') THEN COALESCE(( SELECT SUM(sc.award_amount_cents) FROM public.scholarships sc