From 7f88414b402dee25223fdd856d7b5eface4aa094 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Mon, 11 May 2026 13:56:12 -0500 Subject: [PATCH] Make migration policy creation idempotent DROP POLICY IF EXISTS before CREATE POLICY so migrations can be re-applied to a DB that already has the policy (e.g. demo_config was manually applied before migration tracking was set up). --- migrations/20260510000000_demo_config.sql | 1 + migrations/20260511000000_user_api_keys.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/migrations/20260510000000_demo_config.sql b/migrations/20260510000000_demo_config.sql index 8c1a5c8..1566454 100644 --- a/migrations/20260510000000_demo_config.sql +++ b/migrations/20260510000000_demo_config.sql @@ -15,6 +15,7 @@ CREATE TABLE IF NOT EXISTS public.demo_config ( 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 diff --git a/migrations/20260511000000_user_api_keys.sql b/migrations/20260511000000_user_api_keys.sql index 92f0bf5..5936804 100644 --- a/migrations/20260511000000_user_api_keys.sql +++ b/migrations/20260511000000_user_api_keys.sql @@ -15,4 +15,5 @@ CREATE TABLE IF NOT EXISTS public.user_api_keys ( ); ALTER TABLE public.user_api_keys ENABLE ROW LEVEL SECURITY; +DROP POLICY IF EXISTS "service only" ON public.user_api_keys; CREATE POLICY "service only" ON public.user_api_keys USING (false);