Since we have no ability to name the index, it can happen that the name is more than what PostgreSQL accepts (63 bytes). In this case the name is automatically truncated, but on further migrations the engine is trying to rename the index to the full name.
Good point! I was going to do a writeup about constraint names and how they should be reflected (or not) in the prisma schema — this is definitely going to be part of it. We should fix this.
The constraint names proposal is still being evaluated, I'll work on a stop-gap fix for this issue.
So I had a look at our test suite, and we already migrate index names if you provide a name for the index in the prisma schema: @@index([field1, field2], name: "myIndexName") should create an index named myIndexName. The other part of the issue is validating index name size limits in the prisma schema. There is the issue to track that work: https://github.com/prisma/prisma-engines/issues/962
To avoid this exact situation, where no index name is provided, I'm going to implement comparison on the first 63 bytes for diffing purposes.
Neat I didn't know you could give it a name already. I don't think it is in the doc?
It's probably not in the docs because it's not relevant outside of migrate, and I don't think introspect populates it, and migrate is still experimental. I'll raise the issue.