lumen
06/01/2022, 1:13 AMprofile
table in Prisma, where I want to store all my custom data:
model profile {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique
stripeCustomerId String? @unique
}
Now I want to create a trigger function that runs every time the user signs up with Supabase auth. It looks like this:
begin
insert into public.profile(id, email)
values(new.id, new.email);
return new;
end;
And I set up a trigger to run it every time a user is INSERTed into auth.users
.
Now when I try to sign up with Supabase Auth, I get an error "Database error saving new user", and when I look at Postgres logs, it says "permission denied for table profile".
It worked perfectly fine when I created tables manually via Supabase UI, it stopped working when I tried to create tables with Prisma. What have I done wrong? How can I fix this?Needle
06/01/2022, 1:13 AMjaitaiwan
06/01/2022, 1:27 AMNeedle
06/01/2022, 1:27 AMlumen
06/01/2022, 1:39 AMlumen
06/01/2022, 1:48 AMselique
06/02/2022, 3:44 AMselique
06/02/2022, 3:47 AMjaitaiwan
06/02/2022, 9:36 AMferpintado
06/02/2022, 2:48 PMprisma migrate
so you would need to add the permission back to the table i.e.
ALTER TABLE IF EXISTS public.profiles
OWNER to postgres;
GRANT ALL ON TABLE public.profiles TO authenticated;
GRANT ALL ON TABLE public.profiles TO postgres;
GRANT ALL ON TABLE public.profiles TO anon;
GRANT ALL ON TABLE public.profiles TO service_role;