News for hackers. Stuff that matters.

Show HN: Underrated Postgres: Build Multi-Tenancy with Row-Level Security

https://www.simplyblock.io/blog/underated-postgres-multi-tenancy-with-row-level-security/

Utilizing Postgres' RLS feature to isolate user data instead of easy-to-forget where-clauses, is such an underrated use case, I really wonder why not more people use it.

If you prefer code over the blog post, I've put the full application example on GitHub. Would love to hear your thoughts.

https://github.com/simplyblock/example-rls-invoicing

( 4 comments | 6 points | on HN )
Re:Show HN: Underrated Postgres: Build Multi-Tenancy with Ro... by pwlm on Thursday September 18, 2025 @05:58AM (#45287705)
From Postgres docs https://www.postgresql.org/docs/current/ddl-rowsecurity.html

I built multi-tenant services and never used RLS because it's complicated.

Re:Show HN: Underrated Postgres: Build Multi-Tenancy with Ro... by noctarius on Thursday September 18, 2025 @06:03AM (#45287746)
It is complicated to initially wrap your head around, I agree. That's why I thought a demo application is the best way to show that it doesn't have to be super complicated once understood.

Like many things in PG, they aren't always easy to get right away I remember my first time with it years and years ago.

Re:Show HN: Underrated Postgres: Build Multi-Tenancy with Ro... by MohanYC on Thursday September 18, 2025 @06:01AM (#45287730)
Great share!
Re:Show HN: Underrated Postgres: Build Multi-Tenancy with Ro... by noctarius on Thursday September 18, 2025 @06:04AM (#45287749)
Thank you very much :)

Happy to get any idea on how to make it even better!