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.

Drift detected after prisma migration dev and wants to reset the database?

See original GitHub issue

Trying to to migrate from Prisma 1 to Prisma 2 and all seems to work, i.e. I can query my database fine. Except when running npx prisma migrate dev which seems to think my schema is out of date and says We need to reset the PostgreSQL database

Is there a way I can tell Prisma that the schema in my database is the one I want to keep?

The flow I have done to migrate is as follows:

  1. Using pg_dump to pull down prisma 1 database
  2. Use pg_restore to upload copy of prisma 1 database to a new database
  3. Using npx prisma-upgrade to generate SQL commands to run on new database
  4. Running prisma introspect which shows successful (a few warnings These id fields were enriched with @default(cuid()) information taken from the previous Prisma schema. but shouldn’t be a blocker?)
  5. Run npx prisma generate and can succesfully generate my client which I can use to query data and all seems to work fine
  6. Run prisma migrate dev which is what doesn’t work Drift detected: Your database schema is not in sync with your migration history & We need to reset the PostgreSQL database

I don’t want to reset my database as I’ll lose all my data.

Is it possible to delete these migrations from somewhere so it thinks my database schema is up to date or will that cause issues downt the track?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stretch0commented, Jul 8, 2021

@janpio haven’t been able to get the migration dev working yet but thinking the db push and pull is actually what we were after. We will be doing the actual migration next week so should (just been doing test runs for now) so can report back when we have more info.

1reaction
Gamotecommented, Jul 7, 2021

@janpio sure thing. Here is the new issue: #8124

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >
Prisma Migrate limitations and known issues
You call prisma migrate reset explicitly; You call prisma migrate dev and Prisma Migrate detects drift in the database or a migration history...
Read more >
Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
Read more >
Prisma Migrate in development and production
This command: Reruns the existing migration history in the shadow database in order to detect schema drift (edited or deleted migration file, or...
Read more >
Migration troubleshooting in production - Prisma
Fixing failed migrations with migrate diff and db execute · prisma migrate diff which diffs two database schema sources to create a migration...
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