-- 20260510000000_demo_config.sql -- -- Kill switch for the demo chat endpoint. Backs the budget-alert Cloud Function -- that flips demo_enabled to 'false' when GCP spend crosses 90% of the daily -- budget threshold. The web tier polls this table with a 60s TTL cache so the -- demo is disabled within one minute of a budget alert firing. -- -- Service-role bypasses RLS. Public anon has no access (policy USING (false)). CREATE TABLE IF NOT EXISTS public.demo_config ( key text PRIMARY KEY, value text NOT NULL, updated_at timestamptz DEFAULT now() ); ALTER TABLE public.demo_config ENABLE ROW LEVEL SECURITY; DROP POLICY IF EXISTS "service only" ON public.demo_config; CREATE POLICY "service only" ON public.demo_config USING (false); -- Seed the kill switch as enabled INSERT INTO public.demo_config (key, value) VALUES ('demo_enabled', 'true') ON CONFLICT (key) DO NOTHING;