From 9131a7d2bf331a091a9ab347e14a353abe494a1e Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Wed, 14 Oct 2026 21:34:43 +0000 Subject: [PATCH] fix(ads): ref_slug no longer truncates past campaign 999 lpad(seq::text, 3, '0') truncates longer strings, so campaign 1000 became crawlproof-ad-100 and every new campaign hit ad_campaigns_ref_slug_key. Pad to at least three digits; existing slugs are unchanged. Applied to prod. Co-Authored-By: Claude Opus 5.5 --- .../migrations/20261014120000_ad_ref_slug_past_999.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 supabase/migrations/20261014120000_ad_ref_slug_past_999.sql diff --git a/supabase/migrations/20261014120000_ad_ref_slug_past_999.sql b/supabase/migrations/20261014120000_ad_ref_slug_past_999.sql new file mode 100644 index 0000000..a182235 --- /dev/null +++ b/supabase/migrations/20261014120000_ad_ref_slug_past_999.sql @@ -0,0 +1,7 @@ +-- ref_slug was 'crawlproof-ad-' || lpad(seq::text, 3, '0'). lpad TRUNCATES a +-- longer string to the target length, so campaign 1000 became crawlproof-ad-100 +-- and every insert after the 999th hit ad_campaigns_ref_slug_key. Pad to at +-- least three digits instead: 001..999 are unchanged, 1000+ keep every digit. +alter table public.ad_campaigns + alter column ref_slug set expression as + ('crawlproof-ad-' || lpad(seq::text, greatest(3, length(seq::text)), '0'));