Fixed supabase trigger

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so right now in Super Bass I'm not sure it's like it's a bug or is it like a new feature for it but if you go into the trigger right now and if you want to create a new trigger we have access only to the public tables only so right now what if I wanted to create the trigger from the art user table so the goal is like this so when there's a new user signing into our application you want to call a trigger to insert the record into the table so right now you can see I have this table user right here so that I just created and also I have the function to create user on signing up so whenever the user click login for example lock in GitHub right here and after they finish the process there's automatically inserts the record inside the users table that we have so we need to create a trigger for that and then for the trigger we need to listen to the US table use for the US table and the r table is this one right here so right now we have this record user right here so I'm gonna delete this user and then I'm gonna show you the demo so whenever there's a new record into this all stable you want to create a new record inside our public user table so in order to create a trigger right now uh we have to use the actual editor because from the UI as you can see I show you earlier the trigger right now is available only for the public table even though if you change the schema to the Aus and as you can see right now it's still uh showing public so one way that you can do that is go to actual editor and then I have created everything right here and all the command you can just copy and paste from the descriptions so this one is do exactly our goal is to create a user on sign trigger this one is after the insert on our stable so it means that when the there's a new user insert into the Aus user table so if it inserts so for and then we're gonna call to the function create a sign up so this is going to be a function name so this is going to be a trigger name okay you see it's a trigger name and this is the function name make sure you match the function name uh that you have inside here otherwise it will fails and yeah this one you can name whatever you want because this is just a trigger name and so right now we can just try to run this one let's hit run so when you run this one when you see something like this it's been a successful and if we go into trigger and then we can go to us we can see that we have created and on the table user as well so to demonstrate that if this is working so right now we have this user table which is empty and I'm going to log in with the githubs right here this is my previous apps and so if it works successfully we can't have the user table uh with the new record of this user so if we go back here so you can see everything work as expected I will trigger and the function is working alright so that's how you do it and also I have created the drop trigger as well if you want to remove the trigger because right now we not be able to remove the trigger as well so from the UI and so to do that you can just replace this uh create this one is going to be a trigger name and yeah just run this one and then it will remove it so I'm gonna let's say for example I'm gonna remove this one it seems that I do not write the the wrong the right trigger so come back here so going back to all so we can have this one so I can just copy and paste this one and click run this one and as you can see it's successful and if we go back into the trigger and let's refresh this one let's go to off as you can see the trigger is removed alright so that's how you do it all right hopefully this helps some of you that faces issues all right so don't forget to share like And subscribe for more video like this thank you bye
Info
Channel: Daily Web Coding
Views: 3,302
Rating: undefined out of 5
Keywords: supabase trigger, supabase function, how to create supabase trigger, how to create supabase function
Id: mcrqn77lUmM
Channel Id: undefined
Length: 4min 2sec (242 seconds)
Published: Tue Oct 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.