You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
multiSchema is done for PostgreSQL, CockroachDB and SQLServer but we miss support for MySQL.
Reacted by Eugene Karimov, Paul Auramenka, Ross Lavery, Thorbjörn Tasche, Vinicius Assis, Jason Kleinberg, kevinalmanzar, Steven Kuck, Aleksandrs, Alisson Cavalcante Agiani and 5 more
Reacted by Luan Freitas, Thorbjörn Tasche, Jason Kleinberg and kevinalmanzar
Reacted by Eric Dunaway, Rafael de Siqueira, Max, sacru2red, Ross Lavery, Thorbjörn Tasche, Jason Kleinberg, kevinalmanzar and Aleksandrs
Version 5 was released and this feature here is still open. Please don't forget this, Prisma is very good and I would really like to implement it in our main project.
Reacted by Joël Galeran, Vinicius Assis, kevinalmanzar and Abid Sayyed
Any update on this issue? I know it's still open but we have a MySQL database and we're looking to functionally shard it soon so it can better scale with us.
I'm looking forward to seeing what can be done in this space given the restructuring of how Prisma is handling preview features, given that MySQL is listed as a first-class database in terms of support.
Reacted by kevinalmanzar, Aleksandrs, Abid Sayyed and Steven Bendell
While undocumented - it used to work before version 5.15.0 even with mysql. We are still using 5.14.0 version with multiSchema + mysql and are pretty much stuck with it as it looks like this commit prisma/prisma-engines@ae0473d has broken it.
While undocumented - it used to work before version 5.15.0 even with mysql. We are still using 5.14.0 version with multiSchema + mysql and are pretty much stuck with it as it looks like this commit prisma/prisma-engines@ae0473d has broken it.
As we are working towards bringing the multiSchema feature from preview to general availability, we also had another deeper look into supporting multiple schemas for MySQL.
What we want to achieve with this feature is that users can spread out their models across schemas in their database via a simple @@schema("<schema-name>") attribute on the model in the Prisma schema file and query models across schemas through a single PrismaClient instance (docu).
Note
Please do not confuse this with having multiple Prisma schema files!
You can read more about using multiple Prisma schema files here.
Unfortunately, MySQL does not natively support this layer of abstraction as it treats databases and schemas as synonyms - contrary to the SQL standard and e.g. Postgres and SQL Server.
Important
Hence we have concluded that it is not technically feasible with justifiable efforts and we will not pursue this feature for MySQL for the foreseeable future.
We understand this may be disappointing to some users. However, demand for this feature has been comparatively low. If you have strong demand for this feature please open a new issue describing your specific use-case and motivation.
Alternatives To Use
If you have the need to connect to multiple databases on your MySQL server you can create separate PrismaClient specifications with separate schema files and output directories. These clients can be then used alongside each other to query the databases independently.
Why This Is Not Technically Feasible For Us:
Context:
The SQL standard specifies a “three tiered hierarchy” of: database → schema → table
MySQL, unlike PostgreSQL, does not follow this hierarchy. In MySQL DATABASE and SCHEMA are effectively synonyms. In fact CREATE DATABASE foo and CREATE SCHEMA foo result in the same operation.
Prisma’s migration engine internally uses a so called “shadow database” to perform introspections and schema diffing (read more about it here). The shadow database needs an isolated namespace to create ephemeral tables that can be created and destroyed adhoc by commands such as prisma migrate dev.
Currently that level of isolation of the shadow database is ensured by creating a fresh database via a CREATE DATABASE <generated-tmp-shaddow-db-name> statement.
Problem:
Because CREATE SCHEMA and CREATE DATABASE are equivalent in MySQL, attempting to isolate schemas within a shadow database does not work.
Any CREATE SCHEMA call during a shadow DB operation escapes the intended isolation boundary and creates a new top-level database on the server.
This can interfere with the user’s actual databases and potentially cause destructive side effects.
⇒ In short, we cannot guarantee the isolation required for safe shadow database operations when using multiple schemas in MySQL.
Why We Can’t Work Around It
While theoretical workarounds exist, they all come with serious limitations:
Dynamic SQL rewriting
Attempt to detect and rewrite schema-scoped SQL to use globally unique schema names during shadow database operations.
Highly fragile: migrations may contain arbitrary SQL that’s hard to rewrite safely.
Increases the risk of subtle or destructive errors.
Weakens isolation guarantees.
Require a dedicated MySQL instance
Ask users to provide a fully isolated MySQL server exclusively for the shadow database.
Poor user experience.
High potential for misconfiguration and footguns (e.g., using the same instance unintentionally).
This limitation also impacts our internal testing setup. Without schema-level isolation, we cannot safely run parallel tests on shared MySQL instances, making test setup more complex and brittle.
Additional Considerations:
We also encountered issues when testing with Vitess and PlanetScale-based MySQL setups. These systems use schemas internally for sharding and branching, and may rename schemas in metadata tables needed for introspection. This adds another layer of fragility and complexity, making robust support even more challenging.
Activity
floelhoeffel commentedon Jan 17, 2023
I'll convert this to the main issue tracking support for MySQL for multiSchema
[-]Multi-schema support for `db pull` for MySQL[/-][+]Multi-schema support for MySQL[/+][-]Multi-schema support for MySQL[/-][+]`multiSchema` support for MySQL[/+]ludufre commentedon Jul 11, 2023
Version 5 was released and this feature here is still open. Please don't forget this, Prisma is very good and I would really like to implement it in our main project.
bentleysayer23 commentedon Oct 16, 2023
Any updates on this? We are wanting to switch asap but have been blocked by this for a long time
William-McGonagle commentedon Aug 19, 2024
@Jolg42
Any update on this issue? I know it's still open but we have a MySQL database and we're looking to functionally shard it soon so it can better scale with us.
Ustice commentedon Dec 6, 2024
I'm looking forward to seeing what can be done in this space given the restructuring of how Prisma is handling preview features, given that MySQL is listed as a first-class database in terms of support.
thelinuxlich commentedon Feb 6, 2025
Hoping to see this come to life in 2025 :)
scavlev commentedon Mar 13, 2025
While undocumented - it used to work before version 5.15.0 even with mysql. We are still using 5.14.0 version with multiSchema + mysql and are pretty much stuck with it as it looks like this commit prisma/prisma-engines@ae0473d has broken it.
thelinuxlich commentedon May 2, 2025
Is it supported now that multi schemas are out of preview?
NanNanCHN commentedon May 29, 2025
what about this https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support, did you try it?
thelinuxlich commentedon May 29, 2025
Not the same thing
NanNanCHN commentedon May 30, 2025
i understand
FGoessler commentedon Jul 9, 2025
Important Update On This Feature Request
As we are working towards bringing the
multiSchemafeature from preview to general availability, we also had another deeper look into supporting multiple schemas for MySQL.What we want to achieve with this feature is that users can spread out their models across schemas in their database via a simple
@@schema("<schema-name>")attribute on the model in the Prisma schema file and query models across schemas through a singlePrismaClientinstance (docu).Note
Please do not confuse this with having multiple Prisma schema files!
You can read more about using multiple Prisma schema files here.
Unfortunately, MySQL does not natively support this layer of abstraction as it treats databases and schemas as synonyms - contrary to the SQL standard and e.g. Postgres and SQL Server.
Important
Hence we have concluded that it is not technically feasible with justifiable efforts and we will not pursue this feature for MySQL for the foreseeable future.
We understand this may be disappointing to some users. However, demand for this feature has been comparatively low. If you have strong demand for this feature please open a new issue describing your specific use-case and motivation.
Alternatives To Use
If you have the need to connect to multiple databases on your MySQL server you can create separate
PrismaClientspecifications with separate schema files and output directories. These clients can be then used alongside each other to query the databases independently.Why This Is Not Technically Feasible For Us:
Context:
database→schema→tableDATABASEandSCHEMAare effectively synonyms. In factCREATE DATABASE fooandCREATE SCHEMA fooresult in the same operation.prisma migrate dev.CREATE DATABASE <generated-tmp-shaddow-db-name>statement.Problem:
CREATE SCHEMAandCREATE DATABASEare equivalent in MySQL, attempting to isolate schemas within a shadow database does not work.CREATE SCHEMAcall during a shadow DB operation escapes the intended isolation boundary and creates a new top-level database on the server.Why We Can’t Work Around It
While theoretical workarounds exist, they all come with serious limitations:
Dynamic SQL rewriting
Attempt to detect and rewrite schema-scoped SQL to use globally unique schema names during shadow database operations.
Require a dedicated MySQL instance
Ask users to provide a fully isolated MySQL server exclusively for the shadow database.
This limitation also impacts our internal testing setup. Without schema-level isolation, we cannot safely run parallel tests on shared MySQL instances, making test setup more complex and brittle.
Additional Considerations:
We also encountered issues when testing with Vitess and PlanetScale-based MySQL setups. These systems use schemas internally for sharding and branching, and may rename schemas in metadata tables needed for introspection. This adds another layer of fragility and complexity, making robust support even more challenging.