Migrate in production - drift after adding data to db
See original GitHub issueBug description
w10 - nodejs - mysql - prisma CLI - v2.23
I have a production database running locally for development and i had prisma fine and applied some migrations before
After adding a new model to the schema and using CLI trying to apply it with “npx prisma migrate dev”, I got an error:
"The migration ...........
failed.
- Drift detected: Your database schema is not in sync with your migration history." The CLI warned that the migration cannot be added except after the problem was resolved, but I actually saw the new table being created in the db
How to reproduce
- After 4 successful migrations
- Added relations
- Added data to the db
- Edited prisma schema to add a new table
- See error
Expected behavior
The migration to proceed adding the table without errors or the table is not created and the migration fails
Prisma information
Environment & setup
- OS: W10
- Database: MySQL
- Node.js version: v12.14.1
Prisma Version
Prisma: 2.23
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Migrations - Drift - Simon Binder
Drift provides a migration API that can be used to gradually apply schema changes after bumping the schemaVersion getter inside the Database class....
Read more >Handling Database Drifts in State based vs Migration based ...
A database drift causes the source control and the destination database to be out of sync. However any database drifts will be automatically ......
Read more >Patching / hotfixing a database in production - Prisma
Patching the production database directly results in schema drift: your database schema has 'drifted away' from the source of truth, and is out...
Read more >Flyway Database Drift and How it Happens - Redgate Software
Perhaps the most obvious source of 'drift' will be database changes (deletions, amendments, and additions) made outside of Flyway, through an ...
Read more >Move fast and migrate things: how we automated migrations in ...
Running migrations · Check production database version counter (via Alembic) to determine which pre-deploy migrations from the new commits are ...
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
Hey, the proposed new commands are now out in 3.9. We’ve also included a guide how to do up and down migrations to handle failed migrations. Please check it out and let us know what you think! https://github.com/prisma/prisma/releases/tag/3.9.0
Hey @yazer79 - we have a proposal for some new migrate tooling that helps with failed migrations. Would be awesome if you would take a look and give us some feedback: https://github.com/prisma/prisma/issues/10561