-- 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();