Migrate: Lift up failes with preview-3

Created on 27 Jul 2019  ยท  10Comments  ยท  Source: prisma/migrate

Prisma2 Version: [email protected], binary version: 5f361e08f59d0d21e5510e6c3e65cc8052dca4f7

I installed the preview-3 and create a new project from scratch with prisma2 init hello-prisma. I selected SQLite, Typescript and From Scratch.

prisma2 lift up failes with the error:

๐Ÿ‹๏ธโ€ lift up

Datamodel that will initialize the db:

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

generator photon {
  provider = "photonjs"
  output   = "../node_modules/@generated/photon"
}

model User {
  id    String  @default(cuid()) @id @unique
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?
}

Database Changes:

Migration            Database actions           Status

20190624162221-init  2 CreateTable statements.  

You can get the detailed db changes with prisma2 lift up --verbose
Or read about them in the ./migrations/MIGRATION_ID/README.md
Error: Error in lift engine for rpc migrationProgress:
  thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
  24: __rust_maybe_catch_panic
  25: std::rt::lang_start_internal
  26: main

More output from the failed-migrationProgress file:

Failed migrationProgress at 2019-07-27T11:39:27.335Z

RPC Input One Line

{"id":1,"jsonrpc":"2.0","method":"migrationProgress","params":{"projectInfo":"","migrationId":"20190624162221-init","sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"}}

RPC Input Readable

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "migrationProgress",
  "params": {
    "projectInfo": "",
    "migrationId": "20190624162221-init",
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"
  }
}

RPC Response

null

Stack Trace

thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
  24: __rust_maybe_catch_panic
  25: std::rt::lang_start_internal
  26: main

bu2-confirmed

Most helpful comment

Our apologies, we had a problem with the binary fetching logic, which is now fixed in https://github.com/prisma/prisma2/releases/tag/2.0.0-preview-3.2

All 10 comments

The last alpha it worked with is [email protected]

Thanks a lot for reporting!
Fixed in [email protected]

Hi, I still have the error

Platform: Linux 5.2.3-arch1-1-ARCH

Node: v12.6.0

Prisma2 Version: [email protected], binary version: 611b083079e60345fcb5cb6788755cbff31ba2d3

I tried many config with no success, for this output I selected SQLite, Typescript and From Scratch.

prisma2 lift up failes with the error:

๐Ÿ‹๏ธโ€ lift up

Datamodel that will initialize the db:

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

generator photon {
  provider = "photonjs"
  output   = "../node_modules/@generated/photon"
}

model User {
  id    String  @default(cuid()) @id @unique
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?
}

Database Changes:

Migration            Database actions           Status

20190624162221-init  2 CreateTable statements.  

You can get the detailed db changes with prisma2 lift up --verbose
Or read about them in the ./migrations/MIGRATION_ID/README.md
Error: Error in lift engine for rpc migrationProgress:
  thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::option::expect_failed
             at src/libcore/option.rs:1034
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  24: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  25: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  26: main
  27: __libc_start_main
  28: _start

More output from the failed-migrationProgress file:

Failed migrationProgress at 2019-07-29T17:33:52.265Z

RPC Input One Line

{"id":1,"jsonrpc":"2.0","method":"migrationProgress","params":{"projectInfo":"","migrationId":"20190624162221-init","sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"}}

RPC Input Readable

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "migrationProgress",
  "params": {
    "projectInfo": "",
    "migrationId": "20190624162221-init",
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"
  }
}

RPC Response

null

Stack Trace

thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::option::expect_failed
             at src/libcore/option.rs:1034
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  24: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  25: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  26: main
  27: __libc_start_main
  28: _start

I tested out preview-3.1 [email protected], binary version: 611b083079e60345fcb5cb6788755cbff31ba2d3 and prisma2 lift up still throws an error:

Failed migrationProgress at 2019-07-29T20:02:21.737Z

RPC Input One Line

{"id":1,"jsonrpc":"2.0","method":"migrationProgress","params":{"projectInfo":"","migrationId":"20190729220216-init","sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"}}

RPC Input Readable

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "migrationProgress",
  "params": {
    "projectInfo": "",
    "migrationId": "20190729220216-init",
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"
  }
}

RPC Response

null

Stack Trace

thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190729220216-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
  24: __rust_maybe_catch_panic
  25: std::rt::lang_start_internal
  26: main

Reopen please...

Error still happens in preview-3.1 (It worked in review-2, I did not try preview-3)

prisma2: [email protected], binary version: 611b083079e60345fcb5cb6788755cbff31ba2d3
macOS: 10.14.6
node: v12.5.0

$ prisma2 init
โˆš SQLite
โˆš Photon
โˆš Lift
โˆš Create
โˆš Typescript
โˆš From Scratch
โœ” Downloading starter from https://api.github.com/repos/prisma/photonjs/tarball/master
โœ” Extracting content to /Users/glen/Documents/JavaScript/Research/Lift-test
โœ” Installing dependencies ๐Ÿ‘ฉโ€๐Ÿš€

  Your template has been successfully set up!
$ prisma2 lift save --name init
Everything up-to-date
$ prisma2 lift up
Error: Error in lift engine for rpc migrationProgress:
  thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5


Failed migrationProgress

# Failed migrationProgress at 2019-07-30T00:57:18.191Z
## RPC Input One Line
```json
{"id":1,"jsonrpc":"2.0","method":"migrationProgress","params":{"projectInfo":"","migrationId":"20190624162221-init","sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"}}

RPC Input Readable

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "migrationProgress",
  "params": {
    "projectInfo": "",
    "migrationId": "20190624162221-init",
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./dev.db\"\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\nmodel User {\n  id    String  @default(cuid()) @id @unique\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}"
  }
}

RPC Response

null

Stack Trace

thread 'main' panicked at 'Could not load migration from database. Migration name was: 20190624162221-init', src/libcore/option.rs:1034:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: <migration_core::commands::migration_progress::MigrationProgressCommand as migration_core::commands::command::MigrationCommand>::execute
  10: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  11: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  14: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  15: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  16: futures::task_impl::std::set
  17: std::thread::local::LocalKey<T>::with
  18: futures::future::Future::wait
  19: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  20: migration_core::rpc_api::RpcApi::handle
  21: migration_engine::main
  22: std::rt::lang_start::{{closure}}
  23: std::panicking::try::do_call
  24: __rust_maybe_catch_panic
  25: std::rt::lang_start_internal
  26: main

Can confirm I updated to [email protected] but still get the error.

I have opened #79 before finding this one so close either one :)

Our apologies, we had a problem with the binary fetching logic, which is now fixed in https://github.com/prisma/prisma2/releases/tag/2.0.0-preview-3.2

Thanks, it works :)

Yes it works for me as well. Thanks for the quick fix :)

TLDR; It worked for me too (after some fiddling) ๐Ÿ˜œ

After updating to preview-3.2, I got a different error on prisma2 lift up

Error: Generic("Generic(\"QueryError(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\\"index Post.id._UNIQUE already exists\\"))\n\nstack backtrace:\


Error details
$ prisma2 lift up
๐Ÿ‹๏ธโ€ lift up

Datamodel that will initialize the db:

datasource db {
provider = "sqlite"
url = "file:dev.db"
default = true
}

generator photon {
provider = "photonjs"
}

generator nexus_prisma {
provider = "nexus-prisma"
}

model Post {
id String @default(cuid()) @id @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
published Boolean
title String
content String?
author User?
}

model User {
id String @default(cuid()) @id @unique
email String @unique
password String
name String?
posts Post[]
}

Database Changes:

Migration Database actionsStatus

20190730121826-init statements.

You can get the detailed db changes with prisma2 lift up --verbose
Or read about them in the ./migrations/MIGRATION_ID/README.md
Error: Generic("Generic(\"QueryError(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\\"index Post.id._UNIQUE already exists\\"))\n\nstack backtrace:\
0: backtrace::backtrace::trace::h1a2de69e72ae183d (0x10707e09e)\
1: backtrace::capture::Backtrace::new_unresolved::h930294fe2b60b491 (0x10707c2c8)\
2: failure::backtrace::internal::InternalBacktrace::new::hb4d9ca333d8b97ee (0x10707bc69)\
3: ::default::h84240357500db3cb (0x10707be55)\
4: prisma_query::connector::sqlite::error:: for prisma_query::error::Error>::from::hd42f9694c0c2d894 (0x106ba7dd7)\
5: ::query_raw::h950dca751fd2d2d7 (0x106b5a162)\
6: ::query_raw::h4378aab2bb2b77bf (0x106b0e534)\
7: sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier::apply_next_step::hbc0dd6496fe1877e (0x106acb4b0)\
8: >::apply_step::h8cc20b6775cc37a7 (0x106acae98)\
9: as migration_connector::migration_applier::MigrationApplier>::apply::h1c41d080d1fc2e2d (0x106a7daf9)\
10: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::h791888a176207067 (0x106a05c5a)\
11: ::execute::h6717abed7c636729 (0x106a04ed8)\
12: ::call::h37f67045bdc63ae5 (0x106a4d7b6)\
13: >::call::h58bd453400985a9f (0x1069f609c)\
14: as futures::future::Future>::poll::h4ec51a25c6821507 (0x106a09612)\
15: as futures::future::Future>::poll::h237d5669254ecf15 (0x1069f6880)\
16: as futures::future::Future>::poll::h76b2cfbd5571eb5d (0x106a12dbf)\
17: as futures::future::Future>::poll::hd7ff4e9d1b2217d8 (0x106a09920)\
18: futures::task_impl::std::set::hcdf643d1bd2f42af (0x106a4619f)\
19: std::thread::local::LocalKey::with::h7ae26f1524deb689 (0x106a49e16)\
20: futures::future::Future::wait::h605fe0633ff08219 (0x106a12c0f)\
21: jsonrpc_core::io::IoHandler::handle_request_sync::h066bd9bc4caba49b (0x1069f042f)\
22: migration_core::rpc_api::RpcApi::handle::h7a17577fdd3ef47d (0x106a5648b)\
23: migration_engine::main::hc86c74d4107213aa (0x1069cc74d)\
24: std::rt::lang_start::{{closure}}::h7f81fc3af650a78e (0x1069cc7b6)\
25: std::panicking::try::do_call::h1252fc9a2ff235eb (0x1070a25a8)\
26: __rust_maybe_catch_panic (0x1070a698f)\
27: std::rt::lang_start_internal::h4c054360e442146c (0x1070a308e)\
28: main (0x1069cc7a9))\")")


failed-applyMigration-20190730134559.md

Failed applyMigration at 2019-07-30T20:45:59.791Z

RPC Input One Line

{"id":1,"jsonrpc":"2.0","method":"applyMigration","params":{"projectInfo":"","force":false,"migrationId":"20190730134228-init","steps":[{"stepType":"CreateModel","name":"Post","embedded":false},{"stepType":"CreateModel","name":"User","embedded":false},{"stepType":"CreateField","model":"Post","name":"id","type":{"Base":"String"},"arity":"required","isUnique":true,"id":{"strategy":"Auto","sequence":null},"default":{"Expression":["cuid","String",[]]}},{"stepType":"CreateField","model":"Post","name":"createdAt","type":{"Base":"DateTime"},"arity":"required","isUnique":false,"default":{"Expression":["now","DateTime",[]]}},{"stepType":"CreateField","model":"Post","name":"updatedAt","type":{"Base":"DateTime"},"arity":"required","isUnique":false},{"stepType":"CreateField","model":"Post","name":"published","type":{"Base":"Boolean"},"arity":"required","isUnique":false},{"stepType":"CreateField","model":"Post","name":"title","type":{"Base":"String"},"arity":"required","isUnique":false},{"stepType":"CreateField","model":"Post","name":"content","type":{"Base":"String"},"arity":"optional","isUnique":false},{"stepType":"CreateField","model":"Post","name":"author","type":{"Relation":{"to":"User","to_fields":["id"],"name":"PostToUser","on_delete":"None"}},"arity":"optional","isUnique":false},{"stepType":"CreateField","model":"User","name":"id","type":{"Base":"String"},"arity":"required","isUnique":true,"id":{"strategy":"Auto","sequence":null},"default":{"Expression":["cuid","String",[]]}},{"stepType":"CreateField","model":"User","name":"email","type":{"Base":"String"},"arity":"required","isUnique":true},{"stepType":"CreateField","model":"User","name":"password","type":{"Base":"String"},"arity":"required","isUnique":false},{"stepType":"CreateField","model":"User","name":"name","type":{"Base":"String"},"arity":"optional","isUnique":false},{"stepType":"CreateField","model":"User","name":"posts","type":{"Relation":{"to":"Post","to_fields":[],"name":"PostToUser","on_delete":"None"}},"arity":"list","isUnique":false}],"sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:dev.db\"\n  default  = true\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\ngenerator nexus_prisma {\n  provider = \"nexus-prisma\"\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}\n\nmodel User {\n  id       String  @default(cuid()) @id @unique\n  email    String  @unique\n  password String\n  name     String?\n  posts    Post[]\n}\n"}}

RPC Input Readable

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "applyMigration",
  "params": {
    "projectInfo": "",
    "force": false,
    "migrationId": "20190730134228-init",
    "steps": [
      {
        "stepType": "CreateModel",
        "name": "Post",
        "embedded": false
      },
      {
        "stepType": "CreateModel",
        "name": "User",
        "embedded": false
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "id",
        "type": {
          "Base": "String"
        },
        "arity": "required",
        "isUnique": true,
        "id": {
          "strategy": "Auto",
          "sequence": null
        },
        "default": {
          "Expression": [
            "cuid",
            "String",
            []
          ]
        }
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "createdAt",
        "type": {
          "Base": "DateTime"
        },
        "arity": "required",
        "isUnique": false,
        "default": {
          "Expression": [
            "now",
            "DateTime",
            []
          ]
        }
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "updatedAt",
        "type": {
          "Base": "DateTime"
        },
        "arity": "required",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "published",
        "type": {
          "Base": "Boolean"
        },
        "arity": "required",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "title",
        "type": {
          "Base": "String"
        },
        "arity": "required",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "content",
        "type": {
          "Base": "String"
        },
        "arity": "optional",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "Post",
        "name": "author",
        "type": {
          "Relation": {
            "to": "User",
            "to_fields": [
              "id"
            ],
            "name": "PostToUser",
            "on_delete": "None"
          }
        },
        "arity": "optional",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "User",
        "name": "id",
        "type": {
          "Base": "String"
        },
        "arity": "required",
        "isUnique": true,
        "id": {
          "strategy": "Auto",
          "sequence": null
        },
        "default": {
          "Expression": [
            "cuid",
            "String",
            []
          ]
        }
      },
      {
        "stepType": "CreateField",
        "model": "User",
        "name": "email",
        "type": {
          "Base": "String"
        },
        "arity": "required",
        "isUnique": true
      },
      {
        "stepType": "CreateField",
        "model": "User",
        "name": "password",
        "type": {
          "Base": "String"
        },
        "arity": "required",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "User",
        "name": "name",
        "type": {
          "Base": "String"
        },
        "arity": "optional",
        "isUnique": false
      },
      {
        "stepType": "CreateField",
        "model": "User",
        "name": "posts",
        "type": {
          "Relation": {
            "to": "Post",
            "to_fields": [],
            "name": "PostToUser",
            "on_delete": "None"
          }
        },
        "arity": "list",
        "isUnique": false
      }
    ],
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:dev.db\"\n  default  = true\n}\n\ngenerator photon {\n  provider = \"photonjs\"\n}\n\ngenerator nexus_prisma {\n  provider = \"nexus-prisma\"\n}\n\nmodel Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}\n\nmodel User {\n  id       String  @default(cuid()) @id @unique\n  email    String  @unique\n  password String\n  name     String?\n  posts    Post[]\n}\n"
  }
}

RPC Response

null

Stack Trace

[migration-engine/connectors/sql-migration-connector/src/sql_migration_persistence.rs:39] m.make_from(barrel_variant) = "CREATE TABLE IF NOT EXISTS \"lift\".\"_Migration\" (\"revision\" INTEGER NOT NULL PRIMARY KEY, \"name\" TEXT NOT NULL, \"datamodel\" TEXT NOT NULL, \"status\" TEXT NOT NULL, \"applied\" INTEGER NOT NULL, \"rolled_back\" INTEGER NOT NULL, \"datamodel_steps\" TEXT NOT NULL, \"database_migration\" TEXT NOT NULL, \"errors\" TEXT NOT NULL, \"started_at\" DATE NOT NULL, \"finished_at\" DATE);"
[/var/root/.cargo/git/checkouts/prisma-query-a8c45647247f5d6d/1107e25/src/connector/sqlite.rs:82] visitor::Sqlite::build(q) = (
    "SELECT `_Migration`.* FROM `_Migration` WHERE `status` = ? ORDER BY `revision` DESC",
    [
        Text(
            "MigrationSuccess",
        ),
    ],
)
[/var/root/.cargo/git/checkouts/prisma-query-a8c45647247f5d6d/1107e25/src/connector/sqlite.rs:82] visitor::Sqlite::build(q) = (
    "SELECT `_Migration`.* FROM `_Migration` WHERE `status` = ? ORDER BY `revision` DESC",
    [
        Text(
            "MigrationSuccess",
        ),
    ],
)
[/var/root/.cargo/git/checkouts/prisma-query-a8c45647247f5d6d/1107e25/src/connector/sqlite.rs:75] visitor::Sqlite::build(q) = (
    "INSERT INTO `_Migration` (`name`, `datamodel`, `status`, `applied`, `rolled_back`, `datamodel_steps`, `database_migration`, `errors`, `started_at`, `finished_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
    [
        Text(
            "20190730134228-init",
        ),
        Text(
            "model Post {\n  id        String   @default(cuid()) @id @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime\n  published Boolean\n  title     String\n  content   String?\n  author    User?\n}\n\nmodel User {\n  id       String  @default(cuid()) @id @unique\n  email    String  @unique\n  password String\n  name     String?\n  posts    Post[]\n}",
        ),
        Text(
            "Pending",
        ),
        Integer(
            0,
        ),
        Integer(
            0,
        ),
        Text(
            "[{\"stepType\":\"CreateModel\",\"name\":\"Post\",\"embedded\":false},{\"stepType\":\"CreateModel\",\"name\":\"User\",\"embedded\":false},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"id\",\"type\":{\"Base\":\"String\"},\"arity\":\"required\",\"isUnique\":true,\"id\":{\"strategy\":\"Auto\",\"sequence\":null},\"default\":{\"Expression\":[\"cuid\",\"String\",[]]}},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"createdAt\",\"type\":{\"Base\":\"DateTime\"},\"arity\":\"required\",\"isUnique\":false,\"default\":{\"Expression\":[\"now\",\"DateTime\",[]]}},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"updatedAt\",\"type\":{\"Base\":\"DateTime\"},\"arity\":\"required\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"published\",\"type\":{\"Base\":\"Boolean\"},\"arity\":\"required\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"title\",\"type\":{\"Base\":\"String\"},\"arity\":\"required\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"content\",\"type\":{\"Base\":\"String\"},\"arity\":\"optional\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"Post\",\"name\":\"author\",\"type\":{\"Relation\":{\"to\":\"User\",\"to_fields\":[\"id\"],\"name\":\"PostToUser\",\"on_delete\":\"None\"}},\"arity\":\"optional\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"User\",\"name\":\"id\",\"type\":{\"Base\":\"String\"},\"arity\":\"required\",\"isUnique\":true,\"id\":{\"strategy\":\"Auto\",\"sequence\":null},\"default\":{\"Expression\":[\"cuid\",\"String\",[]]}},{\"stepType\":\"CreateField\",\"model\":\"User\",\"name\":\"email\",\"type\":{\"Base\":\"String\"},\"arity\":\"required\",\"isUnique\":true},{\"stepType\":\"CreateField\",\"model\":\"User\",\"name\":\"password\",\"type\":{\"Base\":\"String\"},\"arity\":\"required\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"User\",\"name\":\"name\",\"type\":{\"Base\":\"String\"},\"arity\":\"optional\",\"isUnique\":false},{\"stepType\":\"CreateField\",\"model\":\"User\",\"name\":\"posts\",\"type\":{\"Relation\":{\"to\":\"Post\",\"to_fields\":[],\"name\":\"PostToUser\",\"on_delete\":\"None\"}},\"arity\":\"list\",\"isUnique\":false}]",
        ),
        Text(
            "{\"steps\":[{\"CreateIndex\":{\"table\":\"Post\",\"name\":\"Post.id._UNIQUE\",\"tpe\":\"Unique\",\"columns\":[\"id\"]}},{\"CreateIndex\":{\"table\":\"User\",\"name\":\"User.id._UNIQUE\",\"tpe\":\"Unique\",\"columns\":[\"id\"]}},{\"CreateIndex\":{\"table\":\"User\",\"name\":\"User.email._UNIQUE\",\"tpe\":\"Unique\",\"columns\":[\"email\"]}}],\"rollback\":[{\"DropIndex\":{\"table\":\"Post\",\"name\":\"Post.id._UNIQUE\"}},{\"DropIndex\":{\"table\":\"User\",\"name\":\"User.id._UNIQUE\"}},{\"DropIndex\":{\"table\":\"User\",\"name\":\"User.email._UNIQUE\"}}]}",
        ),
        Text(
            "[]",
        ),
        Integer(
            1564519554529,
        ),
        Null,
    ],
)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: QueryError(SqliteFailure(Error { code: DatabaseBusy, extended_code: 5 }, Some("database is locked"))

stack backtrace:
   0: backtrace::backtrace::trace::h1a2de69e72ae183d (0x1007d809e)
   1: backtrace::capture::Backtrace::new_unresolved::h930294fe2b60b491 (0x1007d62c8)
   2: failure::backtrace::internal::InternalBacktrace::new::hb4d9ca333d8b97ee (0x1007d5c69)
   3: <failure::backtrace::Backtrace as core::default::Default>::default::h84240357500db3cb (0x1007d5e55)
   4: prisma_query::connector::sqlite::error::<impl core::convert::From<rusqlite::error::Error> for prisma_query::error::Error>::from::hd42f9694c0c2d894 (0x100301dd7)
   5: <prisma_query::connector::sqlite::Sqlite as prisma_query::connector::queryable::Queryable>::execute_raw::h4bb33e32ba2f0796 (0x1002b4a04)
   6: <prisma_query::connector::sqlite::Sqlite as prisma_query::connector::queryable::Queryable>::execute::h3f2eb7c45f5e52cf (0x1002b3bfb)
   7: <sql_migration_connector::migration_database::Sqlite as sql_migration_connector::migration_database::MigrationDatabase>::execute::h235d774437d45120 (0x100268260)
   8: <sql_migration_connector::sql_migration_persistence::SqlMigrationPersistence as migration_connector::migration_persistence::MigrationPersistence>::create::hffe866e0e74b6248 (0x10022dac4)
   9: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::h791888a176207067 (0x10015fc12)
  10: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute::h6717abed7c636729 (0x10015eed8)
  11: <F as jsonrpc_core::calls::RpcMethodSimple>::call::h37f67045bdc63ae5 (0x1001a77b6)
  12: <F as jsonrpc_core::calls::RpcMethod<T>>::call::h58bd453400985a9f (0x10015009c)
  13: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h4ec51a25c6821507 (0x100163612)
  14: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h237d5669254ecf15 (0x100150880)
  15: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h76b2cfbd5571eb5d (0x10016cdbf)
  16: <futures::future::either::Either<A,B> as futures::future::Future>::poll::hd7ff4e9d1b2217d8 (0x100163920)
  17: futures::task_impl::std::set::hcdf643d1bd2f42af (0x1001a019f)
  18: std::thread::local::LocalKey<T>::with::h7ae26f1524deb689 (0x1001a3e16)
  19: futures::future::Future::wait::h605fe0633ff08219 (0x10016cc0f)
  20: jsonrpc_core::io::IoHandler<M>::handle_request_sync::h066bd9bc4caba49b (0x10014a42f)
  21: migration_core::rpc_api::RpcApi::handle::h7a17577fdd3ef47d (0x1001b048b)
  22: migration_engine::main::hc86c74d4107213aa (0x10012674d)
  23: std::rt::lang_start::{{closure}}::h7f81fc3af650a78e (0x1001267b6)
  24: std::panicking::try::do_call::h1252fc9a2ff235eb (0x1007fc5a8)
  25: __rust_maybe_catch_panic (0x10080098f)
  26: std::rt::lang_start_internal::h4c054360e442146c (0x1007fd08e)
  27: main (0x1001267a9))', src/libcore/result.rs:997:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: <sql_migration_connector::sql_migration_persistence::SqlMigrationPersistence as migration_connector::migration_persistence::MigrationPersistence>::create
  10: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration
  11: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute
  12: <F as jsonrpc_core::calls::RpcMethodSimple>::call
  13: <F as jsonrpc_core::calls::RpcMethod<T>>::call
  14: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  15: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  16: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  17: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  18: futures::task_impl::std::set
  19: std::thread::local::LocalKey<T>::with
  20: futures::future::Future::wait
  21: jsonrpc_core::io::IoHandler<M>::handle_request_sync
  22: migration_core::rpc_api::RpcApi::handle
  23: migration_engine::main
  24: std::rt::lang_start::{{closure}}
  25: std::panicking::try::do_call
  26: __rust_maybe_catch_panic
  27: std::rt::lang_start_internal
  28: main

The _Migration table contained entries with Migration Status MigrationFailure:

image

Deleting the records who's name did not match the `./prisma/migrations/{migration-name}, or deleting the the entire _Migration table did not help.

I got things going again, by following these steps:

  1. Export user data from the DB
  2. Delete the dev.db file
  3. Delete ./prisma/migrations folder
  4. prisma2 lift save --name 'init'
  5. prisma2 lift up
  6. Import user data to the DB

And all is good again. ๐ŸŽ‰

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chanphiromsok picture chanphiromsok  ยท  3Comments

jwld picture jwld  ยท  3Comments

divyenduz picture divyenduz  ยท  3Comments

steebchen picture steebchen  ยท  3Comments

hamidb80 picture hamidb80  ยท  4Comments