Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create Triggers for auth schema - Missing "users" table from table dropdown #11

Open
kmiguel10 opened this issue Oct 3, 2023 · 3 comments

Comments

@kmiguel10
Copy link

kmiguel10 commented Oct 3, 2023

I am stuck in chapter 12 because when creating a trigger to watch for a changes in the users table in auth schema , the dropdown for the Table (to watch for) options only shows my 2 public tables which are profiles and tweets but it should show the users table.

From tutorial:
Screenshot 2023-10-03 at 11 29 41 AM

Issue:
Screenshot 2023-10-03 at 11 30 33 AM

Thanks!

@kmiguel10 kmiguel10 changed the title Cannot create Triggers for auth schema Cannot create Triggers for auth schema - Missing "users" table from table dropdown Oct 3, 2023
@jundran
Copy link

jundran commented Oct 12, 2023

I had the same problem using the GUI but I was using the code snippets to create the function and the trigger. These seemed to work but then when I would log in on the app, I would get back a session but supabase would fail to save the user to the auth table. If I deleted the trigger using the query drop trigger <TRIGGER NAME> on auth.users; then supabase would save the user to auth.users but, of course, nothing would be in the profiles table.

I ended up deleting the profiles table, function, trigger and the modifying the User Management Starter template to work with this tutorial. You can see the templates in the SQL editor. Basically, just modify the values to match the values we want in the profiles table. Edit the values in the part for creating the profiles table and the arguments for the public.handle_new_user function. Run it then don't forget to re add the foreign key relation between the tweets table user_id and the profiles table with cascade on delete.

@britotiagos
Copy link

@kmiguel10 you can find the solution for that in this video.

Basically, all you have to do is run this in the SQL editor, changing it to your own information.

  • create the trigger: create trigger trigger_name after insert on auth.users for each row execute function function_name();
  • delete trigger if you need: drop trigger if exists trigger_name on auth.users;

@kevinhellos
Copy link

This is the command that I used, it works for me as of June 5 2024.

CREATE TRIGGER users_insert_trigger
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION insert_profile_for_new_user();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants