Fix email change token schema

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 16:52:59 +00:00
parent 3769c3759b
commit 8cd6a35fcf

View File

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