New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Multi Schema] Same model map different schema #15009
[Multi Schema] Same model map different schema #15009
Comments
Can confirm that the name collision is a bug, the mapped names should be qualified with their schema while checking for mapped name collisions. In terms of implementation, |
The validation we have validates that no two models in the whole schema have the same database name. Database name is defined as the contents of the model's `@@map` attribute, or the model name if the model name does not have an `@@map` attribute. It is the name we give to the table/collection corresponding to the model in the database. When the `multiSchema` preview feature is turned on, the tables in the database can be in different schemas, so we have to adapt the validation to allow multiple models to have the same database name, as long as they are in a different schema. This is what this commit does. closes prisma/prisma#15009
The validation we have validates that no two models in the whole schema have the same database name. Database name is defined as the contents of the model's `@@map` attribute, or the model name if the model name does not have an `@@map` attribute. It is the name we give to the table/collection corresponding to the model in the database. When the `multiSchema` preview feature is turned on, the tables in the database can be in different schemas, so we have to adapt the validation to allow multiple models to have the same database name, as long as they are in a different schema. This is what this commit does. closes prisma/prisma#15009
Opened a PR to adapt the current test #15647 |
Reopening until test from #15647 is merged (currently not passing because engine is not up-to-date) |
In our dev version it now errors with a different error message with #15647 (comment) We want to fix this. |
Bug description
I am using multiSchema, and I have the following schema:
The User model belongs to the
base
schema and it is mapped to thesome_table
tabel name.The Post model belongs to the
transactional
schema and it is mapped to thesome_table
tabel name.I get the error:
How to reproduce
npx prisma migrate dev
Expected behavior
Both models map to the same tabel name
some_table
however, they are in different schemas and so this should work.Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: