Files
thrilltrack-explorer/supabase/migrations/20251103002454_04434de4-ee0a-4106-955b-93fb7bb28b86.sql
2025-11-03 00:25:17 +00:00

20 lines
552 B
SQL

-- 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;