From 7dd2513cd8a45ccb20bb1c35608c350a3a73f8f2 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 7 Aug 2026 20:43:24 +0000 Subject: [PATCH] Terminal --- .../migrations/20260807002000_reporting_view_fixes.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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