Migrate: Bug: Can't save new migration file

Created on 4 May 2020  路  4Comments  路  Source: prisma/migrate

Bug description

Report id: 4772

Running a DEBUG=* npx prisma migrate save --experimental results in the following:

MigrateEngine:stderr {"is_panic":true,"message":"[migration-engine/connectors/migration-connector/src/migration_persistence.rs:84:9] called `Result::unwrap()` on an `Err` value: ErrorCollection { errors: [ParserError { expected: [\"argument name\"], expected_str: \"argument name\", span: Span { start: 954, end: 954 } }] }","backtrace":"   0: backtrace::backtrace::trace\n   1: backtrace::capture::Backtrace::new\n   2: user_facing_errors::Error::new_in_panic_hook\n   3: user_facing_errors::panic_hook::set_panic_hook::{{closure}}\n   4: std::panicking::rust_panic_with_hook\n   5: rust_begin_unwind\n   6: core::panicking::panic_fmt\n   7: core::result::unwrap_failed\n   8: migration_connector::migration_persistence::Migration::parse_schema_ast\n   9: <migration_core::commands::infer_migration_steps::InferMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute::__execute::{{closure}}\n  10: <std::future::GenFuture<T> as core::future::future::Future>::poll\n  11: <std::future::GenFuture<T> as core::future::future::Future>::poll\n  12: <std::future::GenFuture<T> as core::future::future::Future>::poll\n  13: migration_core::api::rpc::RpcApi::run_command::{{closure}}\n  14: <std::future::GenFuture<T> as core::future::future::Future>::poll\n  15: <futures_util::compat::compat03as01::Compat<Fut> as futures::future::Future>::poll\n  16: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll\n  17: futures::future::chain::Chain<A,B,C>::poll\n  18: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll\n  19: <futures::future::map::Map<A,F> as futures::future::Future>::poll\n  20: <futures::future::either::Either<A,B> as futures::future::Future>::poll\n  21: futures::task_impl::std::set\n  22: migration_engine::main::{{closure}}\n  23: tokio::runtime::enter::Enter::block_on\n  24: tokio::runtime::context::enter\n  25: tokio::runtime::handle::Handle::enter\n  26: migration_engine::main\n  27: std::rt::lang_start::{{closure}}\n  28: std::panicking::try::do_call\n  29: __rust_maybe_catch_panic\n  30: std::rt::lang_start_internal\n  31: main\n"} +1s
Error in migration engine.
Reason: [migration-engine/connectors/migration-connector/src/migration_persistence.rs:84:9] called `Result::unwrap()` on an `Err` value: ErrorCollection { errors: [ParserError { expected: ["argument name"], expected_str: "argument name", span: Span { start: 954, end: 954 } }] }

How to reproduce

I don't actually know.

Expected behavior

Can create a new migration file.

Prisma information

Will email schema and/or migration files, when needed.

Environment & setup

  • OS: Mac OS Catalina 10.15.4
  • Database: PostgreSQL running locally within a Docker container
  • Node.js version: v12.16.1

  • Prisma version:

@prisma/cli          : 2.0.0-beta.4
Current platform     : darwin
Query Engine         : query-engine afd294205618b1c825b013ba6f5a6ebe4aa4a514 (at /Users/nickreynke/Code/Git/xxx/node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli afd294205618b1c825b013ba6f5a6ebe4aa4a514 (at /Users/nickreynke/Code/Git/xxx/node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core afd294205618b1c825b013ba6f5a6ebe4aa4a514 (at /Users/nickreynke/Code/Git/xxx/node_modules/@prisma/cli/introspection-engine-darwin)
bu2-confirmed kinbug

Most helpful comment

The error is bad and not readable, we will fix this (by returning a better error).

Here's the solution for now: this error is caused by migrations using an old prisma schema that does not pass validation with newer prisma versions. You can fix the error by deleting your migrations folder and the _Migration table in your database, then re-running migrate save and migrate up.

There should be no data loss, but since migrate is experimental, please back up your data before you do this if it matters :)

All 4 comments

The error is bad and not readable, we will fix this (by returning a better error).

Here's the solution for now: this error is caused by migrations using an old prisma schema that does not pass validation with newer prisma versions. You can fix the error by deleting your migrations folder and the _Migration table in your database, then re-running migrate save and migrate up.

There should be no data loss, but since migrate is experimental, please back up your data before you do this if it matters :)

Ahh, thank you! @tomhoule

https://github.com/prisma/prisma-engines/pull/730 is merged, so the error message will be at least somewhat improved (and it will be easier to tweak).

If deleting the migrations folder and table fixed this for you, I think we can close this issue :) Thanks for reporting the problem!

@tomhoule It certainly did! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julien1619 picture julien1619  路  4Comments

jwld picture jwld  路  3Comments

julien1619 picture julien1619  路  3Comments

chanphiromsok picture chanphiromsok  路  3Comments

marcjulian picture marcjulian  路  4Comments