Prisma migrate dev shadow database error
Problem
When using Prisma with cloud-hosted databases (Prisma Postgres, Neon, Supabase, etc.),
prisma migrate dev fails with shadow database errors like:
Error: P3006 Migration 20251005080724_init failed to apply cleanly to the shadow database. Error: type "ParentageRole" already exists
This happens because Prisma tries to use the same database for both:
1. The application's main database
2. The shadow database (used for migration validation)
Current Documentation Gap
The official migration docs mention shadow databases, but:
- ❌ No clear guidance for cloud database providers
- ❌ No step-by-step setup for Prisma Postgres specifically
- ❌ Error messages don't point users to the solution
- ❌ Many users resort to migrate reset thinking migrations are broken
Solution (that should be documented)
Create a separate shadow db.
For Vercel Integration of Prisma Postgres,
1. Go to Projects->Storage->Create Database-> Select Prisma Postgres-> Select region->Create->Add "SHADOW" as environment variable prefix.
2. Do a vercel env pull
3. Set shadowDatabaseUrl in schema.prisma to SHADOW_DATABASE_URLAbout the shadow database | Prisma Documentation
About the shadow database
2 Replies
You selected to wait for the human sages. They'll share their wisdom soon.
Grab some tea while you wait, or check out
#ask-ai if you'd like a quick chat with the bot anyway!Does this doc not help?
https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database#manually-configuring-the-shadow-database
About the shadow database | Prisma Documentation
About the shadow database