question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrate in production - drift after adding data to db

See original GitHub issue

Bug 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

  1. After 4 successful migrations
  2. Added relations
  3. Added data to the db
  4. Edited prisma schema to add a new table
  5. 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:open
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
do4grcommented, Feb 16, 2022

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

0reactions
floelhoeffelcommented, Dec 3, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found