diff --git a/supabase/migrations/20251001165241_5d90432f-6a24-4328-8d36-ade18b137957.sql b/supabase/migrations/20251001165241_5d90432f-6a24-4328-8d36-ade18b137957.sql new file mode 100644 index 00000000..2619de89 --- /dev/null +++ b/supabase/migrations/20251001165241_5d90432f-6a24-4328-8d36-ade18b137957.sql @@ -0,0 +1,26 @@ +-- Fix all email change token columns to use empty strings instead of NULL +-- This addresses Supabase Auth scanner issues with NULL string columns + +-- Create a function to update all NULL token values to empty strings +CREATE OR REPLACE FUNCTION public.fix_auth_email_tokens() +RETURNS void +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path TO 'auth', 'public' +AS $$ +BEGIN + -- Update all NULL email change token values to empty strings + UPDATE auth.users + SET + email_change_token_current = COALESCE(email_change_token_current, ''), + email_change_token_new = COALESCE(email_change_token_new, '') + WHERE email_change_token_current IS NULL + OR email_change_token_new IS NULL; +END; +$$; + +-- Execute the fix +SELECT public.fix_auth_email_tokens(); + +-- Drop the temporary function +DROP FUNCTION public.fix_auth_email_tokens(); \ No newline at end of file