https://supabase.com/ logo
#help
Title
# help
b

bake

03/08/2022, 5:09 PM
I have enabled RLS on a db table and i have not created any policies, yet i am still able to access the rows in the table. Essentially i've enabled RLS and it seems to not be locking down my table. Anyone know what could be going wrong?
g

garyaustin

03/08/2022, 5:24 PM
How are you accessing the table? The table UI, SQL editor and accesses with service_role key will bypass it.
b

bake

03/08/2022, 8:10 PM
@User I'm accessing it through the supabase client in a nextjs application
g

garyaustin

03/08/2022, 8:10 PM
With anon key?
b

bake

03/08/2022, 8:10 PM
Yes
g

garyaustin

03/08/2022, 8:11 PM
If you want maybe show some code. Sort of opposite the usual RLS problems around here...
b

bake

03/08/2022, 8:13 PM
Lol i noticed
Ok actually I misspoke. I'm using the prisma client. I'm using the supabase client for logging in and out. But here is an example
Copy code
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
  const prisma = new PrismaClient();

  const animals = await prisma.animals.findMany();
  console.log("getting animals", animals);

  return {
    props: { animals: JSON.parse(JSON.stringify(animals)) },
  };
};
g

garyaustin

03/08/2022, 8:16 PM
I don't know much about Prisma but I believe it is logged in thru postgres user so would bypass RLS.
b

bake

03/08/2022, 8:18 PM
I'll get back to googling and let you know if I find anything. Assuming you're interested in the answer. I appreciate the response though
Yeah good call on prisma.
Copy code
Prisma with Supabase RLS policies
For a recent task I had to set up Prisma to take into account RLS (Row Level Security) policies set up in Supabase. This, as you know, is difficult to achieve as by default Prisma opens a direct connection to the database, and that too with the postgres user that has permissions to bypass every RLS policy.
@User from what I'm seeing I'm not thinking that using Prisma is not worth it at this point. What do you use with supabase? just the supabase client?
Also curious how you handle DB migrations
g

garyaustin

03/09/2022, 3:47 PM
I just use client, but I also am just me and a simple app with a simple database. I've not worried about migrations yet. Supabase is working on some minimal migration tools. I also see lots of web info on options. https://github.com/supabase/cli/tree/main/examples/tour https://supabase.com/blog/2021/03/31/supabase-cli
b

bake

03/10/2022, 3:12 PM
thanks!