fix: resolve customer creation fk violation and implement instant updates in admin dialogs
All checks were successful
Staging Build / build (push) Successful in 2m26s

This commit is contained in:
DanielS
2026-06-23 03:27:46 +02:00
parent 898a5253e5
commit 6b76e82220
5 changed files with 35 additions and 2 deletions

View File

@@ -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;