Prisma postgress multi schema + Replica
Hello, I have a question.
I’m working with a PostgreSQL database managed through Prisma. For each customer, I plan to create a separate schema to ensure that their data remains isolated and not mixed with other customers’ data. The database structure will be exactly the same across all schemas — only the schema name will change.
I would like to know:
What is the best way to handle this setup using Prisma?
Is it possible to connect each customer to their own schema through Prisma?
Additionally, is there a way to configure a PostgreSQL replica to another database hosted on a different server?
3 Replies
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the
#ask-ai channel awaits if you're curious!Replica support is coming very soon. Not possible at the moment
For each customer, I plan to create a separate schemaDo you mean a database schema? Or do you want to create different prisma schema files (like different schema.prisma for each customer)
I have a multi-tenant architecture question regarding database connections:
Setup:
4 customers (potentially more in the future)
Each customer has their own database/schema
All databases have identical structure (same tables, columns, relations)
Using a single Prisma schema file
Question:
Is it possible to dynamically switch between different database connections (or schemas) at runtime using the same Prisma schema definition?
Can I instantiate multiple PrismaClient instances with different connection URLs but the same schema?
What's the recommended approach for this multi-tenant scenario?
Are there any performance or connection pooling concerns I should be aware of?
Do I need separate schema files, or can one schema.prisma work for all customers?