Migration failed to apply cleanly to the shadow database
See original GitHub issueBug description
After manually correcting a broken migration and committing it to the DB, I’m now getting the following error when I try to create a new migration with prisma migrate dev --create-only
Error: P3006
Migration `20220425205658_add_reference_to_model` failed to apply cleanly to the shadow database.
Error:
insert or update on table "reference" violates foreign key constraint "reference_model_id_fkey"
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:354
1: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:108
But when I run prisma migrate status
it returns Database schema is up to date!
, so it shouldn’t be returning this error.
How to reproduce
Expected behavior
If a migration is successfully added to the DB, it shouldn’t still be returning errors.
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes", "interactiveTransactions"]
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
Environment & setup
- OS: MacOS 10.15.7
- Database: PostgreSQL
- Node.js version: v14.18.1
Prisma Version
3.4.2
Issue Analytics
- State:
- Created a year ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Error when migrating models to database Prisma
I tried Introspect. But, my DB currently has no tables and that threw an error. I tried npx prisma migrate save -experimental b/c...
Read more >About the shadow database - Prisma
Important: The shadow database is not required in production, and is not used by production-focused commands such as prisma migrate resolve and prisma...
Read more >Impossible prisma (postgreSQL) schema migration - Render
Hello all! I'm facing an issue while trying to migrate my prisma schema: Error: P3014. Prisma Migrate could not create the shadow database....
Read more >Shadow Database or Shadow Schema - Flyway
When setting the shadow database/schema connection, ensure it isn't an important database/schema as this may be cleaned and rebuilt when ...
Read more >Understand the shadow database feature of Prisma ORM
When running a Prisma migration on a cloud-hosted database, you need a shadow database to see your migration succeed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like that worked thanks!
reference_model
isn’t the actual name of my model. It’s just the name I’m using for examples. The names match in my actual migration