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.

Migration dev error

See original GitHub issue

Bug description

Hi,

When doing a migrate dev after a successful migration I’ve got this error

Database error code: 1146

Database error:
Table 'prisma_migrate_shadow_db_530924f1-71bc-41c3-97ed-dc1a6a373b37.versions_old' doesn't exist

But I don’t have this table in my db

Complete error log

Error: P3006

Migration `20220206213143_remove_versions_old` failed to apply cleanly to the shadow database. 
Error code: P3018
Error:
A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20220206213143_remove_versions_old

Database error code: 1146

Database error:
Table 'prisma_migrate_shadow_db_530924f1-71bc-41c3-97ed-dc1a6a373b37.versions_old' doesn't exist

Please check the query number 1 from the migration file.

And the migration file looks like this

/*
  Warnings:

  - You are about to drop the `versions_old` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE `versions_old` DROP FOREIGN KEY `versions_old_ibfk_2`;

-- DropForeignKey
ALTER TABLE `versions_old` DROP FOREIGN KEY `versions_old_ibfk_3`;

-- DropTable
DROP TABLE `versions_old`;

but has already been applied without any issue (I’ve removed a table)

How to reproduce

Expected behavior

Migrate without any issue

Prisma information

Environment & setup

  • OS: Mac Os
  • Database: Mysql 8.0.22
  • Node.js version: v16.13.0

Prisma Version

prisma                  : 3.9.1
@prisma/client          : 3.9.1
Current platform        : darwin
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio                  : 0.457.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
luminous8commented, Mar 5, 2022

Last update and I’ll close the ticket.

I’ve choose an another path (one that was accessible for me in term of knowledge).

  • backed up my prod db content only
  • delete all prisma migratation history and started over
  • generated the db in local based on the schema
  • imported the db content in local
  • exported my local db to prod

And it worked.

It cost me a few minutes of downtime but it was way simpler for me.

I still cannot explain why I’ve had this issue but I’m glad this is over (🤞)

1reaction
tomhoulecommented, Feb 10, 2022

The error message is different in your last comment. Would you be comfortable sharing the 20220209213808_ migration? (it’s not the one about version_old).

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 >
Troubleshoot migration import to Azure DevOps Services
The data migration tool flags errors that you need to correct prior to performing a migration to Azure DevOps Services. This article describes ......
Read more >
How do I resolve database migration error due to changed ...
After making the changes, I deployed to dev and asked for a code review. In code review, it was suggested I change the...
Read more >
Core data migration. Fatal error. … | Apple Developer Forums
Hello Apple, I am using coredata in my current application. But getting error in migration process for rare users - "The database disk...
Read more >
Error: Migration from old dev tool
Error : Migration from old dev tool · Force-Directed Graph Visual. · What am I doing wrong? · All the errors I get...
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