Refactor Novu registration to frontend

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 13:16:06 +00:00
parent b3ecc19717
commit 69aa186e12
5 changed files with 241 additions and 13 deletions

View File

@@ -0,0 +1,26 @@
-- Drop the problematic functions that try to call edge functions from database
DROP FUNCTION IF EXISTS public.migrate_existing_users_to_novu();
DROP FUNCTION IF EXISTS public.register_novu_subscriber(uuid);
-- Update handle_new_user to only create the profile (remove Novu registration)
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = public
AS $$
BEGIN
-- Create profile record
INSERT INTO public.profiles (user_id, username, display_name)
VALUES (
NEW.id,
COALESCE(NEW.raw_user_meta_data ->> 'username', 'user_' || substring(NEW.id::text, 1, 8)),
COALESCE(NEW.raw_user_meta_data ->> 'display_name', NEW.raw_user_meta_data ->> 'name')
);
-- Novu registration will be handled by the frontend
RETURN NEW;
END;
$$;
COMMENT ON FUNCTION public.handle_new_user IS 'Creates user profile on signup. Novu registration is handled by frontend.';