prisma / migrate

Issues for Prisma Migrate are now tracked at prisma/prisma. This repo was used to track issues for Prisma Migrate Experimental and is now deprecated.
https://www.prisma.io/docs/concepts/components/prisma-migrate
Apache License 2.0
766 stars 22 forks source link

Failing to apply new migration causes "Could not load migration from database. ..." #642

Closed timhall closed 3 years ago

timhall commented 3 years ago

Bug description

I have a migration step that is failing with the following output when using DEBUG=*:

MigrateEngine:stderr Nov 10 15:59:03.440  INFO ApplyMigration{migration_id="20201109214059-..."}: migration_core::commands::apply_migration: There are unexecutable migration steps, the migration will not be applied.

This is ok and I can look into the issue. The problem is that this underlying issue fails to report because migration progress fails on the following line: https://github.com/prisma/prisma-engines/blob/ebf0f4d10e5b5e396811addb862c01449d05c81a/migration-engine/core/src/commands/migration_progress.rs#L20. My understanding is that since it's a new migration it hasn't been written to the database yet and therefore reading from the db is failing. This throws the following error:

Error: Error in command input: Could not load migration from database. Migration name was: 20201109214059-...

Much less helpful error message. A few additional details:

  1. migrate save and then migrate up were run against a local DB
  2. migrate up against remove DB warns "There will be data loss: ..."
Database Changes:

Migration                            Database actions             Status

20201109214059-...  3 CreateTable statements.    

How to reproduce

prisma migrate up --experimental

Prisma information

Environment & setup

@prisma/cli          : 2.11.0
@prisma/client       : 2.11.0
Current platform     : darwin
Query Engine         : query-engine 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ../../node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ../../node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ../../node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ../../node_modules/@prisma/engines/prisma-fmt-darwin)
Studio               : 0.311.0
lailo commented 3 years ago

I'm having the same issue. Did you find a solution @timhall ?

timhall commented 3 years ago

Not yet, ended up upgrading to early access. Had to restart that project's migrations from scratch, but it's working well so far.

tomhoule commented 3 years ago

Thanks for taking the time to report this issue!

We've recently released a Prisma Migrate Preview (2.1.3.0 release notes), which has quite a few changes compared to the previous experimental version. We believe this issue is no longer relevant in this new version, so we are closing this.

We would encourage you to try out Prisma Migrate Preview. If you come across this or any other issue in the preview version, please feel free to open a new issue in prisma/prisma. For general feedback on Prisma Migrate Preview, feel free to chime in on this issue.