Hi guys, since I migrated to version 3.x.x, when I...
# orm-help
d
Hi guys, since I migrated to version 3.x.x, when I generate a migration Prisma add a lot of index renaming absolutely not related to the changes I did in my schema. More over when I tried to apply the migration generated, it throws an error indicating the renamed index doesn’t exist. Any idea of the issue ?
d
Hi, this is covered in the upgrade guide, this specific issue you have flagged is covered here. I would advise reading the whole thing to ensure there are no other breaking changes for you
💯 1
👍 1
d
Thanks Dominic, I suspected the renaming was related to the upgrade, but the fix in the migration guide is basically to apply the migration. That’s what I wanted to do but it throws an error in my case. Anyway I have a track to explore now, thanks 😉 !
ok, so I generated the migration for the upgrade, it contains a bunch of indexes renaming as expected. The problem is that Prisma try to rename this index:
ALTER INDEX "users.email_unique" RENAME TO "users_email_key";
But when I try to applied this migration it fails, simply because this index do not exist in my DB. If I apply the migration without this renaming everything is ok. Also when I verified if the index
users.email_unique
existed, it wasn’t but I found I had a lot of
users_email_key_xx
is it normal ?
d
that's very strange, can you confirm you have the original index in your production database? you may need to have to manually add it to your development database to keep parity without having to do a reset
d
I used the last backup of my production database and restored it locally on my laptop so my dev environment is exactly the same than my production.
So this index exists nowhere...
d
so the
users.email_unique
never existed?
I have had instances where some indexes are dropped when restoring from a backup
so it could exist in production just not in local, I usually just readd them manually
d
so the 
users.email_unique
 never existed?
I find it nowhere
I have had instances where some indexes are dropped when restoring from a backup
Yep but Prisma try to rename it into
users_email_key
, and this one already exist ...
d
That's all really strange
d
I finally found a workaround, but didn’t find the root cause 🤷‍♂️
d
very strange, glad to hear it got sorted