Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Bug: Can't save new migration file #435

Closed
joeyaurel opened this issue May 4, 2020 · 4 comments
Closed

Bug: Can't save new migration file #435

joeyaurel opened this issue May 4, 2020 · 4 comments
Assignees
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Milestone

Comments

@joeyaurel
Copy link

joeyaurel commented May 4, 2020

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)
@joeyaurel joeyaurel changed the title Bug: Can't save migration Bug: Can't save new migration file May 4, 2020
@tomhoule tomhoule self-assigned this May 4, 2020
@tomhoule tomhoule added the kind/bug A reported bug. label May 4, 2020
@tomhoule
Copy link
Contributor

tomhoule commented May 4, 2020

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 :)

@joeyaurel
Copy link
Author

Ahh, thank you! @tomhoule

@tomhoule
Copy link
Contributor

tomhoule commented May 4, 2020

prisma/prisma-engines#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!

@janpio janpio added the bug/2-confirmed We have confirmed that this is a bug. label May 4, 2020
@joeyaurel
Copy link
Author

@tomhoule It certainly did! Thank you!

@janpio janpio added this to the Beta 5 milestone May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

3 participants