Created
September 3, 2021 10:28
-
-
Save jasonho-lynx/e13b15304b41a2674b797811efcd1df1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- trigger function is created here (not the actual trigger). | |
CREATE OR REPLACE FUNCTION insert_into_public_users() | |
RETURNS TRIGGER AS $$ | |
BEGIN | |
INSERT INTO public.users (id, email, created_at) | |
VALUES(NEW.id, NEW.email, NOW()); | |
RETURN NEW; | |
END; | |
$$ | |
LANGUAGE plpgsql SECURITY DEFINER; | |
-- defining a trigger on the auth.users table. | |
-- calls the insert_into_public_users() trigger function for every row that is inserted into auth.users. | |
CREATE TRIGGER on_signup | |
AFTER INSERT ON auth.users | |
FOR EACH ROW EXECUTE PROCEDURE insert_into_public_users(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment