© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
6 replies
jdgamble555

RLS on Likes Table

I have 3 Tables;

users
- id
- ...

posts
- id
- author (fk to users.id)
- ...

likes
- pid (fk to posts.id)
- uid (fk to users.id)
(PK = pid + uid)
users
- id
- ...

posts
- id
- author (fk to users.id)
- ...

likes
- pid (fk to posts.id)
- uid (fk to users.id)
(PK = pid + uid)


And I'm trying to create a universal policy where users can like their own posts (CRUD), but this doesn't work:

(role() = 'authenticated'::text) AND (uid = uid() AND pid.author = uid())
(role() = 'authenticated'::text) AND (uid = uid() AND pid.author = uid())

I get this error:
Error adding policy: failed to create pg.policies: missing FROM-clause entry for table "pid"
Error adding policy: failed to create pg.policies: missing FROM-clause entry for table "pid"

This seems pretty basic, but my mind keeps exploding right now.

J
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RLS on related table
SupabaseSSupabase / help-and-questions
8mo ago
Security RLS policy on users table
SupabaseSSupabase / help-and-questions
7mo ago
RLS Policy on a link table
SupabaseSSupabase / help-and-questions
4y ago
RLS on INSERT with linking table
SupabaseSSupabase / help-and-questions
4y ago