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)


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())

I get this error:
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
Was this page helpful?