-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Removing @unique
from 1:n relation scalar field not picked up by Migrate
#5401
Comments
I have a test reproduction for this problem. It is MySQL-specific. |
This is still reproducible in 2.26.0-dev.46 |
Note: We could add a relation validation to make clear that this is actually not a 1:n but a 1:1. |
I am encountering a similar issue from the standpoint of The project I am working on currently is using:
Also the constraints are added with the engines for Windows and Ubuntu (tried Ubuntu to see if any luck), and also with the final version of Prisma 2 - prisma@2.30.3 . Other team members have encountered this issue a handful of times. Work around: |
Hi @twofingerrightclick, thanks for the report. Would you be ok sharing your a reproduction? Also, are you sure this is a 1:n relation and not a 1:1 relation? (1:n would be |
@twofingerrightclick There's an issue about this: #10503 — it's the only case where Prisma implicitly adds indexes/constraints even if they're not in your schema, and I'd like to get rid of it, but it will be a breaking change (so it's going to be for Prisma 4 at the earliest). |
any ETA on this? @janpio |
We are currently cleaning up the 1:1 case (#10503), afterwards Prisma should be consistent how we deal with |
@janpio I am pretty sure this is not related to any of the relation uniqueness issues we have dealt with recently. |
Is there any news regarding it? |
@janpio Any updates on this? I am able to reproduce with a relation that used to be one-to-one with a unique index on foreignIdHere - then converted to a one-to-many with the @ unique removed. MySQL 8. |
Steps
@unique
from fieldenvelopeId
and run prisma migrate dev. Prisma Migrate will claim the database is in sync and not drop the index.Notes
In general, this is a bit of an edge case, because adding the uniqueness constraint, turns the 1:n relation into a 1:1 relation. Usually, developers would utilize our specific 1:1 syntax for this.
It does impact potentially developers who may be transitioning from a 1:1 to a 1:n relation. Surely if they have defined the uniqueness constraint manually (Prisma already creates such an index under the hood).
The text was updated successfully, but these errors were encountered: