mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 04:51:11 -05:00
Implement monitor-rate-limits edge function to compare metrics against alert configurations, trigger notifications, and record alerts; update config and groundwork for admin UI integration.
22 lines
705 B
PL/PgSQL
22 lines
705 B
PL/PgSQL
-- Fix security warning: Set search_path for rate limit alert function
|
|
-- Drop trigger first, then function, then recreate with proper search_path
|
|
|
|
DROP TRIGGER IF EXISTS update_rate_limit_alert_config_updated_at ON public.rate_limit_alert_config;
|
|
DROP FUNCTION IF EXISTS update_rate_limit_alert_config_updated_at();
|
|
|
|
CREATE OR REPLACE FUNCTION update_rate_limit_alert_config_updated_at()
|
|
RETURNS TRIGGER
|
|
LANGUAGE plpgsql
|
|
SECURITY DEFINER
|
|
SET search_path = public
|
|
AS $$
|
|
BEGIN
|
|
NEW.updated_at = now();
|
|
RETURN NEW;
|
|
END;
|
|
$$;
|
|
|
|
CREATE TRIGGER update_rate_limit_alert_config_updated_at
|
|
BEFORE UPDATE ON public.rate_limit_alert_config
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION update_rate_limit_alert_config_updated_at(); |