fix: resolve customer creation fk violation and implement instant updates in admin dialogs
All checks were successful
Staging Build / build (push) Successful in 2m26s
All checks were successful
Staging Build / build (push) Successful in 2m26s
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- Trigger, um Profile automatisch bei User-Erstellung in auth.users anzulegen
|
||||
CREATE OR REPLACE FUNCTION public.handle_new_user()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
INSERT INTO public.profiles (id)
|
||||
VALUES (new.id)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql SECURITY DEFINER;
|
||||
|
||||
CREATE OR REPLACE TRIGGER on_auth_user_created
|
||||
AFTER INSERT ON auth.users
|
||||
FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
|
||||
|
||||
-- Profile für bereits existierende Benutzer anlegen (Backfill)
|
||||
INSERT INTO public.profiles (id)
|
||||
SELECT id FROM auth.users
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
Reference in New Issue
Block a user