We recently migrated a big NestJS project to adopt Prisma as the ORM. It turned out to be a great decision, and I described our wonderful experience in a recent blog post. The project is an API backend for a multi-tenant system, where each tenant has...

Markdown supported · ⌘↵ to post
Hi, I'm curious. Since you have a database per tenant, how do you make sure all those databases share the same structure and get all the latest migrations?
Very neat solution, congrats; I just want to point out a little detail (and please correct me if I'm wrong), you don't need to explicitly make prismaClientProvider request-scpoed, since you are injecting REQUEST into it, wich is in itself a request-scpoed provider, then his scope is bubbled up by the injection chain.
Hi Dario,
thanks for the excellent write-up!
I was wondering, what alternative would you consider if you do have potentially thousands of tenants? I suppose you would then simply have to create the prisma connections based on incoming request?
Levandoski Levi
Dario Ielardi Thank you very much for this article. I have a project to develop that respects this architecture. I would like to know if the tenant databases must be created manually? if I have a frontent with angular for example, how to identify a tenant when creating an account from the front for example and save it in the right database?. A code example would help me more. Thanks in advance