PrismaP
Prisma8mo ago
3 replies
XenTobias

How to Handle Partial Unique Indexes with Prisma Migrations?

Hey Community,

I'm working on a use case where I need to manually modify a Prisma migration file to add a WHERE clause to a unique index. For example:

CREATE UNIQUE INDEX "workflow_releases_active_workflow_id_key" 
ON "workflow_releases"("active", "workflow_id") 
WHERE "active" = true;


The issue is that Prisma doesn't recognize this line afterwards. When I run prisma migrate dev, it tries to add the unique constraint again:

⚠️  Warnings for the current datasource:

  • A unique constraint covering the columns `[active, workflow_id]` on the table `workflow_releases` will be added. If there are existing duplicate values, this will fail.


Is there any known workaround to prevent Prisma from re-adding this constraint?

Thanks in advance!
Was this page helpful?