Prisma creates invalid migration when removing an index

theres a issue on github #26251 about a migration that duplicates a previous foreign key constraint name. that makes you need drop all data. There some way to fix without use relationMode as prisma?
2 Replies
Prisma AI Help
Prisma AI Help•4d ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP. Based on the information provided in the knowledge sources, I can address this issue. The problem you're referring to is indeed described in GitHub Issue #26251, which discusses Prisma creating an invalid migration when removing an index. The issue describes that when removing an index and running a migration, Prisma creates a migration that duplicates a previous foreign key constraint name. This results in an error (P3018) with a "Duplicate foreign key constraint name" message. Unfortunately, the knowledge sources don't provide a direct solution to fix this issue without using relationMode: "prisma". The issue is still open and under investigation by the Prisma team. However, as a workaround, you could try the following: 1. Manually edit the generated migration file before applying it. 2. Remove the problematic queries that are duplicating the foreign key constraints. 3. Apply the modified migration. Keep in mind that this is not an official solution and may have unintended consequences. It's always recommended to test thoroughly in a non-production environment before applying any changes to your database schema. If this workaround doesn't solve your problem or if you need a more robust solution, I would recommend following the GitHub issue for updates or reaching out to the Prisma team directly for further assistance. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul•4d ago
I see this issue https://github.com/prisma/prisma/issues/26251 was confirmed as reproducible by my colleague, so it indeed looks like a bug. Our engineering team will tackle this soon.
GitHub
Prisma creates invalid migration when removing an index · Issue #26...
Bug description For the simple schema below, when removing an index and then running a migration, prisma creates a migration that duplicates a previous foreign key constraint name. The duplicate co...

Did you find this page helpful?