From 8cd6a35fcf85fbc985ab74b4352f0abf5e472ca8 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 16:52:59 +0000 Subject: [PATCH] Fix email change token schema --- ...1_5d90432f-6a24-4328-8d36-ade18b137957.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 supabase/migrations/20251001165241_5d90432f-6a24-4328-8d36-ade18b137957.sql 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