ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamโ€ข12mo agoโ€ข
3 replies
hussam_3h

RLS doesn't work when managing policies with Drizzle?

This is taking to long to understand and I would be grateful for some help!!!

I have my schema distributed between a number of different files grouped by the table's functions/needs. All these files are in my
src/schemas
src/schemas
directory. One of these files is dedicated for policies. Nothing crazy. Something like image 1.

userProfiles
userProfiles
for example is correctly being imported โœ…, drizzle-kit check passes with flying colors โœ…, a push or a migrate call runs smoothly โœ… and everything is being created in Supabase as expected โœ…. Or so I think? ๐Ÿค”

I am following @rphlmr โšก 's
createDrizzle
createDrizzle
flow in his SupaSecureSlack example nearly exactly based on my app's needs. Here's whats done so far:

1. tables created with
.enableRls()
.enableRls()

2. policy is being added in the policies file similar to the example above.
3. new role for
rls_client
rls_client
was created and is being used for the
client
client
connection
4. tables are seeded with dummy rows
5. using
createDrizzle
createDrizzle
to create a
createDrizzleSupabaseClient()
createDrizzleSupabaseClient()
function exactly like the example.
5. drizzle config looks like Image 2

The issue:
when running
db.rls((tx)=> tx.select().from(userProfiles)
db.rls((tx)=> tx.select().from(userProfiles)
as an example, I get zero rows back. Running
db.admin.select().from(useProfiles)
db.admin.select().from(useProfiles)
returns the right rows. So RLS is kinda working, but not really, because I definitely have the right policy. I can see it was created in Supabase. BUT, if I add a new policy directly inside of Supabase UI, exactly similar to the one already exists, then rls works. Can someone make it make sense? :nomore: ๐Ÿฅน
image.png
image.png
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

RLS and Policies
Drizzle TeamDTDrizzle Team / help
3y ago
Query in drizzle doesn't work
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle-zod doesn't work with Array in pg
Drizzle TeamDTDrizzle Team / help
3y ago
`drizzle-kit generate:sqlite` doesn't work
Drizzle TeamDTDrizzle Team / help
2y ago