Hey! Can i set triggers on auth.users?
# help
h
Hey! Can i set triggers on auth.users?
s
This is covered in the Supabase documentation
h
is it? Any chance you could send a link?
@User i'm currently doing this but get errors:
Copy code
sql
CREATE OR REPLACE FUNCTION users_insert_trigger_fnc()
    RETURNS trigger AS
$$
BEGIN
    INSERT INTO public.users (id, username, avatar_url, email)
    VALUES (NEW.id, NEW.raw_user_meta_data ->> "username", NEW.raw_user_meta_data ->> "avatar_url", NEW.email);
    RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';

CREATE TRIGGER users_insert_trigger
    AFTER INSERT
    ON auth.users
    FOR EACH ROW
EXECUTE PROCEDURE users_insert_trigger_fnc();
Copy code
?error=server_error&error_description=Database+error+saving+new+user
I think i found it,
NEW.raw_user_meta_data ->> "username"
should have been
NEW.raw_user_meta_data ->> "user_name"
It's hard to debug as the gotrue logs aren't updating :/
All fixed now!