Skip to content

Commit 9131a7d

Browse files
ralyodioclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 1c51cd1 commit 9131a7d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- ref_slug was 'crawlproof-ad-' || lpad(seq::text, 3, '0'). lpad TRUNCATES a
2+
-- longer string to the target length, so campaign 1000 became crawlproof-ad-100
3+
-- and every insert after the 999th hit ad_campaigns_ref_slug_key. Pad to at
4+
-- least three digits instead: 001..999 are unchanged, 1000+ keep every digit.
5+
alter table public.ad_campaigns
6+
alter column ref_slug set expression as
7+
('crawlproof-ad-' || lpad(seq::text, greatest(3, length(seq::text)), '0'));

0 commit comments

Comments
 (0)