From 036df6f5b788e1bb6e18ffb2116bc5710a55980a Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 00:25:17 +0000 Subject: [PATCH] Fix notification view security --- ...4_04434de4-ee0a-4106-955b-93fb7bb28b86.sql | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 supabase/migrations/20251103002454_04434de4-ee0a-4106-955b-93fb7bb28b86.sql diff --git a/supabase/migrations/20251103002454_04434de4-ee0a-4106-955b-93fb7bb28b86.sql b/supabase/migrations/20251103002454_04434de4-ee0a-4106-955b-93fb7bb28b86.sql new file mode 100644 index 00000000..9146373e --- /dev/null +++ b/supabase/migrations/20251103002454_04434de4-ee0a-4106-955b-93fb7bb28b86.sql @@ -0,0 +1,20 @@ +-- Fix: Remove SECURITY DEFINER from notification_health_dashboard view + +-- Drop and recreate view without SECURITY DEFINER +DROP VIEW IF EXISTS public.notification_health_dashboard; + +CREATE VIEW public.notification_health_dashboard +WITH (security_invoker = true) AS +SELECT + date, + total_attempts, + duplicates_prevented, + prevention_rate, + CASE + WHEN prevention_rate > 10 THEN 'critical' + WHEN prevention_rate > 5 THEN 'warning' + ELSE 'healthy' + END as health_status +FROM public.notification_duplicate_stats +ORDER BY date DESC +LIMIT 30; \ No newline at end of file