From 0cce446e2723f6c277663a69716afeedfefbee49 Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 16 Jul 2026 08:48:51 +0200 Subject: [PATCH] fix: enforce minimum length for auto-generated usernames --- supabase/migrations/20260716090000_profiles_username.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supabase/migrations/20260716090000_profiles_username.sql b/supabase/migrations/20260716090000_profiles_username.sql index 4cd7f88..2e2879e 100644 --- a/supabase/migrations/20260716090000_profiles_username.sql +++ b/supabase/migrations/20260716090000_profiles_username.sql @@ -21,7 +21,7 @@ begin base := lower(regexp_replace(r.name, '\s+', '.', 'g')); base := regexp_replace(base, '[^a-z0-9._-]', '', 'g'); base := substring(base from 1 for 30); - if base = '' then + if length(base) < 3 then base := 'user' || substring(r.id::text from 1 for 8); end if; @@ -60,7 +60,7 @@ begin base := lower(regexp_replace(coalesce(new.raw_user_meta_data ->> 'name', new.email), '\s+', '.', 'g')); base := regexp_replace(base, '[^a-z0-9._-]', '', 'g'); base := substring(base from 1 for 30); - if base = '' then + if length(base) < 3 then base := 'user' || substring(new.id::text from 1 for 8); end if;