I am building a next js app with authentication and user data. I am trying supabase for the first time and used some online help to create some tables and triggers to save user information in profile table. Authentication is working fine without any trigger but when I write the trigger to save the info in profile table authentication fails. Is it necessary to match the field names in profile table and user table.
CREATE OR REPLACE FUNCTION handle_new_user()
RETURNS trigger AS $$
BEGIN
INSERT INTO profiles (id, full_name, avatar_url)
VALUES (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
RETURN new;
END;
$$ language plpgsql security definer;
CREATE TRIGGER on_auth_user_created
AFTER INSERT ON auth.users
FOR EACH ROW EXECUTE PROCEDURE handle_new_user();
