Closed austincollinpena closed 4 years ago
Thanks for reporting this bug! looking at the generated SQL in the migrations folder, it looks like it's the same issue as https://github.com/prisma/migrate/issues/365 - it should be fixed on alpha already, but another PR is on its way with a more general solution.
report id 3574
Bug description
When I run migrations, I get an error stating:
However, if I remove my two migration files and run it again (kept in the repo so this step too could be reproduced), I get the same error, but this time my database gets updated.
How to reproduce
I made a repo, all that needs to be done is to run the migrations. Repo here
In order to reproduce, you must first run the first migration, add several fields of data to the "Link" model with no relations (There is a mutation set up already for this), and then run the next mutations.
Key Point: I bet my schema below is not set up correctly for non nullable fields. Because I already had 4 records and tried to add relational fields, I bet that caused the issue. How should I structure my schema to avoid this and allow nullable relation fields?
When I dropped my tables and re-ran migrations all went well.
Expected behavior
I expect the migrations to work with no errors.
Prisma information
Can be seen here
And schema below (issue is likely here)
Environment & setup