Migrate: Deletion of a foreign key field fails

Created on 25 Sep 2019  ยท  8Comments  ยท  Source: prisma/migrate

Prisma version: [email protected], binary version: 2292f8d0c3bd11fe9cca7c6df4a10061bf58fd18

I am trying to remove a foreign key from my schema.prisma, but I get the following error when I try to apply the migration:

Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1828 (HY000): Cannot drop column '$prisma_fk_name': needed in a foreign key constraint '$fk_constraint' }

The SQL it generates looks like:
ALTER TABLE $db.$table DROP COLUMN $db_column_name,
ADD COLUMN $prisma_fk_name varchar(191) ,
ADD FOREIGN KEY ($prisma_fk_name) REFERENCES $db.$other_table($fk_column_name) ON DELETE SET NULL;

bu2-confirmed kinbug

Most helpful comment

The issue was fixed in https://github.com/prisma/prisma-engine/pull/103

The fix will be in the next release (alpha 252/preview 15).

All 8 comments

Minimal repro would look something like the following.
Imagine I have this in my schema.prisma and I have set up a database with data in it using this schema.

model User {
  name String @id
  address Address @map("address_name")
}

Now I want to migrate to the following schema:

model User {
  name String @id
}

Running prisma2 lift save works, but then prisma2 lift up causes the above issue

@nlarusstone I am unable to reproduce this, can you please share your full schema, in this smaller example, it did not break.

Do you think usage of @map had to do with it?

I have the same problem using the following (simple) prisma.schema:

generator photon {
  provider = "photonjs"
}

datasource db {
  provider = "mysql"
  url      = "mysql://user:pass@localhost:3306/prisma"
}

model User {
    id              String            @default(cuid()) @id
    actions     Action[]        @relation(name: "UserActions", onDelete: CASCADE)   
}

model Action { 
    id            String              @default(cuid()) @id
    type        String          
    value       Int                   @default(0)
    owner     User                @relation(name: "UserActions")
    test         String          

    createdAt   DateTime    @default(now())  
}

I run the following commands:

  • prisma2 lift save --name init
  • prisma2 lift up

Everything works as expected.

I remove the test field from the Action model.

Then, I run the following commands:

  • prisma2 lift save --name first
  • prisma2 lift up

The save command works, then the up command fails with error Error: Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1828 (HY000): Cannot drop column 'owner': needed in a foreign key constraint 'action_ibfk_1' } as shown bellow:

  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +1ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +6ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +2ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +1ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +1ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +1ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  snapdragon:compiler initializing /usr/local/lib/node_modules/prisma2/build/index.js +1ms
  snapdragon:parser initializing /usr/local/lib/node_modules/prisma2/build/index.js +0ms
  LiftEngine:rpc SENDING RPC CALL { id: 1,
  jsonrpc: '2.0',
  method: 'listMigrations',
  params:
   { projectInfo: '',
     sourceConfig:
      'generator photon {\n  provider = "photonjs"\n}\n\ndatasource db {\n  provider = "mysql"\n  url      = "mysql://user:pass@localhost:3306/prisma"\n}\n\nmodel User {\n    id          String          @default(cuid()) @id\n    actions     Action[]        @relation(name: "UserActions", onDelete: CASCADE)   \n}\n\nmodel Action { \n    id          String          @default(cuid()) @id\n    type        String          \n    value       Int             @default(0)\n    owner       User            @relation(name: "UserActions")\n\n    createdAt   DateTime        @default(now())  \n}' } } +0ms
๐Ÿ‹๏ธโ€ lift up

Changes to be applied:
model Action {
    id String @default(cuid()) @id
    type String
    value Int @default(0)
    owner User @relation(name: "UserActions")
    test String
    createdAt DateTime @default(now())
}
  LiftEngine:rpc SENDING RPC CALL { id: 2,
  jsonrpc: '2.0',
  method: 'calculateDatabaseSteps',
  params:
   { projectInfo: '',
     assumeToBeApplied:
      [ { stepType: 'CreateModel', name: 'User', embedded: false },
        { stepType: 'CreateModel', name: 'Action', embedded: false },
        { stepType: 'CreateField',
          model: 'User',
          name: 'id',
          type: { Base: 'String' },
          arity: 'required',
          isUnique: false,
          id: { strategy: 'Auto', sequence: null },
          default: { Expression: [ 'cuid', 'String', [] ] } },
        { stepType: 'CreateField',
          model: 'User',
          name: 'actions',
          type:
           { Relation:
              { to: 'Action',
                to_fields: [],
                name: 'UserActions',
                on_delete: 'Cascade' } },
          arity: 'list',
          isUnique: false },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'id',
          type: { Base: 'String' },
          arity: 'required',
          isUnique: false,
          id: { strategy: 'Auto', sequence: null },
          default: { Expression: [ 'cuid', 'String', [] ] } },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'type',
          type: { Base: 'String' },
          arity: 'required',
          isUnique: false },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'value',
          type: { Base: 'Int' },
          arity: 'required',
          isUnique: false,
          default: { Int: 0 } },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'owner',
          type:
           { Relation:
              { to: 'User',
                to_fields: [ 'id' ],
                name: 'UserActions',
                on_delete: 'None' } },
          arity: 'required',
          isUnique: false },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'test',
          type: { Base: 'String' },
          arity: 'required',
          isUnique: false },
        { stepType: 'CreateField',
          model: 'Action',
          name: 'createdAt',
          type: { Base: 'DateTime' },
          arity: 'required',
          isUnique: false,
          default: { Expression: [ 'now', 'DateTime', [] ] } } ],
     stepsToApply:
      [ { stepType: 'DeleteField', model: 'Action', name: 'test' } ],
     sourceConfig:
      'generator photon {\n  provider = "photonjs"\n}\n\ndatasource db {\n  provider = "mysql"\n  url      = "mysql://user:pass@localhost:3306/prisma"\n}\n\nmodel User {\n    id          String          @default(cuid()) @id\n    actions     Action[]        @relation(name: "UserActions", onDelete: CASCADE)   \n}\n\nmodel Action { \n    id          String          @default(cuid()) @id\n    type        String          \n    value       Int             @default(0)\n    owner       User            @relation(name: "UserActions")\n\n    createdAt   DateTime        @default(now())  \n}' } } +23ms

Database Changes:

Migration             Database actionsStatus

20190928140825-first   statements.

You can get the detailed db changes with prisma2 lift up --verbose
Or read about them in the ./migrations/MIGRATION_ID/README.md
  LiftEngine:rpc SENDING RPC CALL { id: 3,
  jsonrpc: '2.0',
  method: 'applyMigration',
  params:
   { projectInfo: '',
     force: false,
     migrationId: '20190928140825-first',
     steps:
      [ { stepType: 'DeleteField', model: 'Action', name: 'test' } ],
     sourceConfig:
      'generator photon {\n  provider = "photonjs"\n}\n\ndatasource db {\n  provider = "mysql"\n  url      = "mysql://user:pass@localhost:3306/prisma"\n}\n\nmodel User {\n    id          String          @default(cuid()) @id\n    actions     Action[]        @relation(name: "UserActions", onDelete: CASCADE)   \n}\n\nmodel Action { \n    id          String          @default(cuid()) @id\n    type        String          \n    value       Int             @default(0)\n    owner       User            @relation(name: "UserActions")\n\n    createdAt   DateTime        @default(now())  \n}' } } +18ms
Error: Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1828 (HY000): Cannot drop column 'owner': needed in a foreign key constraint 'action_ibfk_1' }

stack backtrace:
   0: backtrace::backtrace::trace::h524ecfdd393411f3 (0x101a5668e)
   1: backtrace::capture::Backtrace::new_unresolved::h8d6789af3312f608 (0x101a548b8)
   2: failure::backtrace::internal::InternalBacktrace::new::hbf925d548de29ff5 (0x101a54249)
   3: <failure::backtrace::Backtrace as core::default::Default>::default::hff32e8d36bbb16df (0x101a54445)
   4: prisma_query::connector::mysql::error::<impl core::convert::From<mysql::error::Error> for prisma_query::error::Error>::from::h5eb4988ead6cc05c (0x1015f2404)
   5: prisma_query::connector::metrics::query::h9753408e3c2972de (0x1015b85f4)
   6: <prisma_query::connector::mysql::Mysql as prisma_query::connector::queryable::Queryable>::query_raw::h550b1c93408f591d (0x1015c4a56)
   7: <sql_migration_connector::migration_database::Mysql as sql_migration_connector::migration_database::MigrationDatabase>::query_raw::h52af0d8e4d019f1d (0x1014c3bcb)
   8: sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier::apply_next_step::hde468b10701d4efd (0x101514358)
   9: <sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier as migration_connector::database_migration_step_applier::DatabaseMigrationStepApplier<sql_migration_connector::sql_migration::SqlMigration>>::apply_step::h5813ce68b44aa127 (0x1015140b5)
  10: <migration_connector::migration_applier::MigrationApplierImpl<T> as migration_connector::migration_applier::MigrationApplier<T>>::apply::h7583b5e69c9b95b3 (0x101475029)
  11: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::hc28579e8909148e8 (0x1014510e1)
  12: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute::h79d917cd2c55caf7 (0x10145063e)
  13: <migration_core::api::MigrationApi<C,D> as migration_core::api::GenericApi>::apply_migration::ha8fe8a92994a34d7 (0x10148cb2f)
  14: migration_core::api::rpc::RpcApi::create_sync_handler::ha026000f6045a25e (0x10144a1fb)
  15: tokio_threadpool::blocking::blocking::h09b55d6f9862bb5c (0x10148810d)
  16: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h5700289aaecdd6fb (0x101450326)
  17: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::hff537bde63115c5a (0x10148beb0)
  18: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h7a8138c3e6474efb (0x101a73ff8)
  19: futures::future::chain::Chain<A,B,C>::poll::h000c1763d696cbc3 (0x101a72760)
  20: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h9d2f82a1c9831944 (0x101a6f78e)
  21: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h5e09b32873f71b65 (0x101a6ec7f)
  22: <futures::future::either::Either<A,B> as futures::future::Future>::poll::habade3c0397b5732 (0x101a74740)
  23: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h077f3897131d3bfb (0x101a6e656)
  24: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::he5983e66084ecded (0x101a741ba)
  25: <futures::stream::and_then::AndThen<S,F,U> as futures::stream::Stream>::poll::h9b89203d836ea71d (0x101a73107)
  26: <futures::stream::forward::Forward<T,U> as futures::future::Future>::poll::h0690e1a9d1790524 (0x101a6d58b)
  27: <futures::future::map::Map<A,F> as futures::future::Future>::poll::hdcd8c4569a25e868 (0x101a6ee44)
  28: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::hd5c9fd789ed4e067 (0x101a740f8)
  29: futures::task_impl::std::set::hcc65f0f9e4c302d8 (0x101aa3aad)
  30: futures::task_impl::Spawn<T>::poll_future_notify::h3a90556c76621886 (0x101aa494f)
  31: std::panicking::try::do_call::hec1d7226ada57755 (0x101aa7ae4)
  32: __rust_maybe_catch_panic (0x101b5286f)
  33: tokio_threadpool::task::Task::run::hfc68ef1064552180 (0x101aa808a)
  34: tokio_threadpool::worker::Worker::run_task::h15d247c88ec703cd (0x101a9fe72)
  35: tokio_threadpool::worker::Worker::run::haf4d21cf00dad972 (0x101a9f39a)
  36: std::thread::local::LocalKey<T>::with::hce2f956d03c8e592 (0x101a88256)
  37: std::thread::local::LocalKey<T>::with::ha155d0e1f193003d (0x101a8812e)
  38: std::thread::local::LocalKey<T>::with::heb5a91d0667d37f9 (0x101a88437)
  39: tokio::runtime::threadpool::builder::Builder::build::{{closure}}::h53031d9c13fd8e69 (0x101a82731)
  40: std::thread::local::LocalKey<T>::with::h0cb357502fcac171 (0x101aa8589)
  41: std::thread::local::LocalKey<T>::with::h374ffeee436b9edd (0x101aa86ba)
  42: std::sys_common::backtrace::__rust_begin_short_backtrace::h4b3c98eb291b884c (0x101aaa702)
  43: std::panicking::try::do_call::hb1fa592bceecf786 (0x101aa7aa0)
  44: __rust_maybe_catch_panic (0x101b5286f)
  45: core::ops::function::FnOnce::call_once{{vtable.shim}}::h3befce0b9cf88d79 (0x101aa15e7)
  46: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8766009c029bc09 (0x101b3f29e)
  47: std::sys::unix::thread::Thread::new::thread_start::hfdef4649a42cf26c (0x101b51dde)
  48: _pthread_body (0x7fff64a3d2eb)
  49: _pthread_start (0x7fff64a40249))

stack backtrace:
   0: backtrace::backtrace::trace::h524ecfdd393411f3 (0x101a5668e)
   1: backtrace::capture::Backtrace::new_unresolved::h8d6789af3312f608 (0x101a548b8)
   2: failure::backtrace::internal::InternalBacktrace::new::hbf925d548de29ff5 (0x101a54249)
   3: <failure::backtrace::Backtrace as core::default::Default>::default::hff32e8d36bbb16df (0x101a54445)
   4: sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier::apply_next_step::hde468b10701d4efd (0x1015144a0)
   5: <sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier as migration_connector::database_migration_step_applier::DatabaseMigrationStepApplier<sql_migration_connector::sql_migration::SqlMigration>>::apply_step::h5813ce68b44aa127 (0x1015140b5)
   6: <migration_connector::migration_applier::MigrationApplierImpl<T> as migration_connector::migration_applier::MigrationApplier<T>>::apply::h7583b5e69c9b95b3 (0x101475029)
   7: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::hc28579e8909148e8 (0x1014510e1)
   8: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute::h79d917cd2c55caf7 (0x10145063e)
   9: <migration_core::api::MigrationApi<C,D> as migration_core::api::GenericApi>::apply_migration::ha8fe8a92994a34d7 (0x10148cb2f)
  10: migration_core::api::rpc::RpcApi::create_sync_handler::ha026000f6045a25e (0x10144a1fb)
  11: tokio_threadpool::blocking::blocking::h09b55d6f9862bb5c (0x10148810d)
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h5700289aaecdd6fb (0x101450326)
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::hff537bde63115c5a (0x10148beb0)
  14: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h7a8138c3e6474efb (0x101a73ff8)
  15: futures::future::chain::Chain<A,B,C>::poll::h000c1763d696cbc3 (0x101a72760)
  16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h9d2f82a1c9831944 (0x101a6f78e)
  17: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h5e09b32873f71b65 (0x101a6ec7f)
  18: <futures::future::either::Either<A,B> as futures::future::Future>::poll::habade3c0397b5732 (0x101a74740)
  19: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h077f3897131d3bfb (0x101a6e656)
  20: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::he5983e66084ecded (0x101a741ba)
  21: <futures::stream::and_then::AndThen<S,F,U> as futures::stream::Stream>::poll::h9b89203d836ea71d (0x101a73107)
  22: <futures::stream::forward::Forward<T,U> as futures::future::Future>::poll::h0690e1a9d1790524 (0x101a6d58b)
  23: <futures::future::map::Map<A,F> as futures::future::Future>::poll::hdcd8c4569a25e868 (0x101a6ee44)
  24: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::hd5c9fd789ed4e067 (0x101a740f8)
  25: futures::task_impl::std::set::hcc65f0f9e4c302d8 (0x101aa3aad)
  26: futures::task_impl::Spawn<T>::poll_future_notify::h3a90556c76621886 (0x101aa494f)
  27: std::panicking::try::do_call::hec1d7226ada57755 (0x101aa7ae4)
  28: __rust_maybe_catch_panic (0x101b5286f)
  29: tokio_threadpool::task::Task::run::hfc68ef1064552180 (0x101aa808a)
  30: tokio_threadpool::worker::Worker::run_task::h15d247c88ec703cd (0x101a9fe72)
  31: tokio_threadpool::worker::Worker::run::haf4d21cf00dad972 (0x101a9f39a)
  32: std::thread::local::LocalKey<T>::with::hce2f956d03c8e592 (0x101a88256)
  33: std::thread::local::LocalKey<T>::with::ha155d0e1f193003d (0x101a8812e)
  34: std::thread::local::LocalKey<T>::with::heb5a91d0667d37f9 (0x101a88437)
  35: tokio::runtime::threadpool::builder::Builder::build::{{closure}}::h53031d9c13fd8e69 (0x101a82731)
  36: std::thread::local::LocalKey<T>::with::h0cb357502fcac171 (0x101aa8589)
  37: std::thread::local::LocalKey<T>::with::h374ffeee436b9edd (0x101aa86ba)
  38: std::sys_common::backtrace::__rust_begin_short_backtrace::h4b3c98eb291b884c (0x101aaa702)
  39: std::panicking::try::do_call::hb1fa592bceecf786 (0x101aa7aa0)
  40: __rust_maybe_catch_panic (0x101b5286f)
  41: core::ops::function::FnOnce::call_once{{vtable.shim}}::h3befce0b9cf88d79 (0x101aa15e7)
  42: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8766009c029bc09 (0x101b3f29e)
  43: std::sys::unix::thread::Thread::new::thread_start::hfdef4649a42cf26c (0x101b51dde)
  44: _pthread_body (0x7fff64a3d2eb)
  45: _pthread_start (0x7fff64a40249))

stack backtrace:
   0: backtrace::backtrace::trace::h524ecfdd393411f3 (0x101a5668e)
   1: backtrace::capture::Backtrace::new_unresolved::h8d6789af3312f608 (0x101a548b8)
   2: failure::backtrace::internal::InternalBacktrace::new::hbf925d548de29ff5 (0x101a54249)
   3: <failure::backtrace::Backtrace as core::default::Default>::default::hff32e8d36bbb16df (0x101a54445)
   4: <failure::error::error_impl::ErrorImpl as core::convert::From<F>>::from::h153731c9d02708b1 (0x1014c0cdd)
   5: <sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier as migration_connector::database_migration_step_applier::DatabaseMigrationStepApplier<sql_migration_connector::sql_migration::SqlMigration>>::apply_step::h5813ce68b44aa127 (0x1015140e4)
   6: <migration_connector::migration_applier::MigrationApplierImpl<T> as migration_connector::migration_applier::MigrationApplier<T>>::apply::h7583b5e69c9b95b3 (0x101475029)
   7: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::hc28579e8909148e8 (0x1014510e1)
   8: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute::h79d917cd2c55caf7 (0x10145063e)
   9: <migration_core::api::MigrationApi<C,D> as migration_core::api::GenericApi>::apply_migration::ha8fe8a92994a34d7 (0x10148cb2f)
  10: migration_core::api::rpc::RpcApi::create_sync_handler::ha026000f6045a25e (0x10144a1fb)
  11: tokio_threadpool::blocking::blocking::h09b55d6f9862bb5c (0x10148810d)
  12: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h5700289aaecdd6fb (0x101450326)
  13: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::hff537bde63115c5a (0x10148beb0)
  14: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h7a8138c3e6474efb (0x101a73ff8)
  15: futures::future::chain::Chain<A,B,C>::poll::h000c1763d696cbc3 (0x101a72760)
  16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h9d2f82a1c9831944 (0x101a6f78e)
  17: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h5e09b32873f71b65 (0x101a6ec7f)
  18: <futures::future::either::Either<A,B> as futures::future::Future>::poll::habade3c0397b5732 (0x101a74740)
  19: <futures::future::map::Map<A,F> as futures::future::Future>::poll::h077f3897131d3bfb (0x101a6e656)
  20: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::he5983e66084ecded (0x101a741ba)
  21: <futures::stream::and_then::AndThen<S,F,U> as futures::stream::Stream>::poll::h9b89203d836ea71d (0x101a73107)
  22: <futures::stream::forward::Forward<T,U> as futures::future::Future>::poll::h0690e1a9d1790524 (0x101a6d58b)
  23: <futures::future::map::Map<A,F> as futures::future::Future>::poll::hdcd8c4569a25e868 (0x101a6ee44)
  24: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::hd5c9fd789ed4e067 (0x101a740f8)
  25: futures::task_impl::std::set::hcc65f0f9e4c302d8 (0x101aa3aad)
  26: futures::task_impl::Spawn<T>::poll_future_notify::h3a90556c76621886 (0x101aa494f)
  27: std::panicking::try::do_call::hec1d7226ada57755 (0x101aa7ae4)
  28: __rust_maybe_catch_panic (0x101b5286f)
  29: tokio_threadpool::task::Task::run::hfc68ef1064552180 (0x101aa808a)
  30: tokio_threadpool::worker::Worker::run_task::h15d247c88ec703cd (0x101a9fe72)
  31: tokio_threadpool::worker::Worker::run::haf4d21cf00dad972 (0x101a9f39a)
  32: std::thread::local::LocalKey<T>::with::hce2f956d03c8e592 (0x101a88256)
  33: std::thread::local::LocalKey<T>::with::ha155d0e1f193003d (0x101a8812e)
  34: std::thread::local::LocalKey<T>::with::heb5a91d0667d37f9 (0x101a88437)
  35: tokio::runtime::threadpool::builder::Builder::build::{{closure}}::h53031d9c13fd8e69 (0x101a82731)
  36: std::thread::local::LocalKey<T>::with::h0cb357502fcac171 (0x101aa8589)
  37: std::thread::local::LocalKey<T>::with::h374ffeee436b9edd (0x101aa86ba)
  38: std::sys_common::backtrace::__rust_begin_short_backtrace::h4b3c98eb291b884c (0x101aaa702)
  39: std::panicking::try::do_call::hb1fa592bceecf786 (0x101aa7aa0)
  40: __rust_maybe_catch_panic (0x101b5286f)
  41: core::ops::function::FnOnce::call_once{{vtable.shim}}::h3befce0b9cf88d79 (0x101aa15e7)
  42: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8766009c029bc09 (0x101b3f29e)
  43: std::sys::unix::thread::Thread::new::thread_start::hfdef4649a42cf26c (0x101b51dde)
  44: _pthread_body (0x7fff64a3d2eb)
  45: _pthread_start (0x7fff64a40249))
    at Object.registerCallback.response (/usr/local/lib/node_modules/prisma2/build/index.js:134300:40)
    at LiftEngine.handleResponse (/usr/local/lib/node_modules/prisma2/build/index.js:134218:42)
    at LineStream.byline_1.default.on.line (/usr/local/lib/node_modules/prisma2/build/index.js:134278:26)
    at LineStream.emit (events.js:198:13)
    at LineStream.EventEmitter.emit (domain.js:448:20)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at LineStream.Readable.push (_stream_readable.js:224:10)
    at LineStream.Transform.push (_stream_transform.js:151:32)
    at LineStream.module.exports.LineStream._pushBuffer (/usr/local/lib/node_modules/prisma2/build/index.js:229135:23)

This was tested with MySQL Ver 5.7.20 for osx10.13 on x86_64 (Homebrew)

The prisma empty schema existed in the local environment, and was created to skip the CLI confirmation on creating a new schema. That is also the reason of using the --name argument.

The prisma2 version was the latest ([email protected])

Basically what I tried to is to delete a simple String field from a model, nothing fancy, and the migration fails.

Hope it helps in reproducing the issue on your side.

@Constans I am still unable to reproduce with Preview 13. I followed the same steps that you mentioned.

I will have some more people try it internally though ๐Ÿ™Œ

I was able to reproduce the issue. Repo: https://github.com/tomhoule/prisma2-lift-issue-147-repro

I haven't been able to determine a pattern for when it happens or doesn't happen. On the first try I was able to produce the issue by removing a foreign key, but when trying the same migrations on a fresh database it worked. The linked repo contains a migration with 2 foreign keys being deleted at the same time, and that fails even when starting on a fresh, empty database.

@Constans I am still unable to reproduce with Preview 13. I followed the same steps that you mentioned.

I will have some more people try it internally though ๐Ÿ™Œ

@divyenduz, I may try to reproduce in a Windows environment, if it helps.

I get it every time on Mac, in the environment that I mentioned, with that schema and that alteration.

@tomhoule has a reproduction and he works at Prisma, so I am marking this as confirmed bug + a candidate for the next sprint ๐Ÿ™Œ

The issue was fixed in https://github.com/prisma/prisma-engine/pull/103

The fix will be in the next release (alpha 252/preview 15).

Was this page helpful?
0 / 5 - 0 ratings