Multi-tenant approaches
I'm trying to figure out a multi-tenant approach and it's really confusing. I prefer to use a single postgresql DB and the RLS functionality looks ideal, but it also looks like it doesn't work with Prisma.
This library was recently put into read-only
https://github.com/Errorname/prisma-multi-tenant
The Zenstack approach looks nice, but it adds a pretty big library and I haven't done enough research to know what I'm taking on.
https://zenstack.dev/docs/the-complete-guide/part1/access-policy/
I'm also trying to figure out how well this works. I can't tell if it's just a prototype or if it's a stable approach
https://github.com/prisma/prisma-client-extensions/tree/main/row-level-security
Any suggestions? thanks
GitHub
GitHub - Errorname/prisma-multi-tenant: 🧠Use Prisma as a multi-ten...
🧠Use Prisma as a multi-tenant provider for your application - Errorname/prisma-multi-tenant
Access Policy | ZenStack
Introduction
GitHub
prisma-client-extensions/row-level-security at main · prisma/prisma...
Examples of Prisma Client extensions. Contribute to prisma/prisma-client-extensions development by creating an account on GitHub.
2 Replies
I have a library that does this in NestJS but the concepts translate to anything
https://github.com/sabinadams/nestjs-prisma-module
GitHub
GitHub - sabinadams/nestjs-prisma-module: A NestJS module that allo...
A NestJS module that allows you use Prisma, set up multiple Prisma services, and use multi-tenancy in each Prisma service. - sabinadams/nestjs-prisma-module
Thanks. Looks like this takes the approach of having separate DBs for each tenant. I think for my purposes a single DB is preferable. I'm hoping to get RLS in Postgres working. Part of the trick was simply to create a new DB user that doesn't have full access. That took me too long to figure out 🙂