Personel Sayfası ve Uygulama renk değişiklikleri
This commit is contained in:
19
supabase/migrations/20240317000001_user_sync_trigger.sql
Normal file
19
supabase/migrations/20240317000001_user_sync_trigger.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Create a trigger function to handle new user registration
|
||||
CREATE OR REPLACE FUNCTION public.handle_new_user()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
INSERT INTO public.users (id, email, first_name, last_name)
|
||||
VALUES (
|
||||
NEW.id,
|
||||
NEW.email,
|
||||
NEW.raw_user_meta_data->>'first_name',
|
||||
NEW.raw_user_meta_data->>'last_name'
|
||||
);
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql SECURITY DEFINER;
|
||||
|
||||
-- Trigger the function every time a user is created
|
||||
CREATE TRIGGER on_auth_user_created
|
||||
AFTER INSERT ON auth.users
|
||||
FOR EACH ROW EXECUTE PROCEDURE public.handle_new_user();
|
||||
Reference in New Issue
Block a user