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

Migration fails with: "Error: Error in migration engine: thread 'tokio-runtime-worker-3' panicked at 'called `Result::unwrap()`" #150

Closed nikolasburk closed 4 years ago

nikolasburk commented 5 years ago

This is my Prisma schema for a SQLite DB:

datasource db {
  provider = "sqlite"
  url      = "file:./northwind.db"
}

model Category {
  category_id  Int       @id
  categoryName String    @map("category_name")
  description  String?
  products     Product[]

  @@map("categories")
}

model Customer {
  customer_id  String  @default(cuid()) @id
  address      String?
  city         String?
  companyName  String  @map("company_name")
  contactName  String? @map("contact_name")
  contactTitle String? @map("contact_title")
  country      String?
  // customerCustomerDemo CustomerCustomerDemo[]
  fax          String?
  orders       Order[]
  phone        String?
  postalCode   String? @map("postal_code")
  region       String?

  @@map("customers")
}

// model CustomerCustomerDemo {
//   customer     Customer            @map("customer_id")
//   customerType CustomerDemographic @map("customer_type_id")

//   @@map("customer_customer_demo")
// }

model CustomerDemographic {
  customer_type_id String  @default(cuid()) @id
  // customerCustomerDemo CustomerCustomerDemo[]
  customerDesc     String? @map("customer_desc")

  @@map("customer_demographics")
}

model Employee {
  employee_id         Int                 @id
  address             String?
  birthDate           DateTime?           @map("birth_date")
  city                String?
  country             String?
  // employees           Employee[]
  employeeTerritories EmployeeTerritory[]
  extension           String?
  firstName           String              @map("first_name")
  hireDate            DateTime?           @map("hire_date")
  homePhone           String?             @map("home_phone")
  lastName            String              @map("last_name")
  notes               String?
  orders              Order[]
  photoPath           String?             @map("photo_path")
  postalCode          String?             @map("postal_code")
  region              String?
  reportsTo           Employee?           @map("reports_to")
  title               String?
  titleOfCourtesy     String?             @map("title_of_courtesy")

  @@map("employees")
}

model EmployeeTerritory {
  order_id Int @id

  employee  Employee  @map("employee_id")
  territory Territory @map("territory_id")

  @@map("employee_territories")
}

model Order {
  order_id       Int       @id
  customer       Customer? @map("customer_id")
  employee       Employee? @map("employee_id")
  freight        Float?
  orderDate      DateTime? @map("order_date")
  // orderDetails   OrderDetail[]
  requiredDate   DateTime? @map("required_date")
  shipAddress    String?   @map("ship_address")
  shipCity       String?   @map("ship_city")
  shipCountry    String?   @map("ship_country")
  shipName       String?   @map("ship_name")
  shippedDate    DateTime? @map("shipped_date")
  shipPostalCode String?   @map("ship_postal_code")
  shipRegion     String?   @map("ship_region")
  shipVia        Shipper?  @map("ship_via")

  @@map("orders")
}

// model OrderDetail {
//   /// Multiple ID fields (compound indexes) are not supported
//   // product_id Product @id
//   /// Multiple ID fields (compound indexes) are not supported
//   // order_id   Order   @id
//   discount   Float
//   quantity   Int
//   unitPrice  Float   @map("unit_price")

//   @@map("order_details")
// }

model Product {
  product_id      Int       @id
  category        Category? @map("category_id")
  discontinued    Int
  // orderDetails    OrderDetail[]
  productName     String    @map("product_name")
  quantityPerUnit String?   @map("quantity_per_unit")
  reorderLevel    Int?      @map("reorder_level")
  supplier        Supplier? @map("supplier_id")
  unitPrice       Float?    @map("unit_price")
  unitsInStock    Int?      @map("units_in_stock")
  unitsOnOrder    Int?      @map("units_on_order")

  @@map("products")
}

model Region {
  region_id         Int         @id
  regionDescription String      @map("region_description")
  territories       Territory[]

  @@map("region")
}

model Shipper {
  shipper_id  Int     @id
  companyName String  @map("company_name")
  orders      Order[]
  phone       String?

  @@map("shippers")
}

model Supplier {
  supplier_id  Int       @id
  address      String?
  city         String?
  companyName  String    @map("company_name")
  contactName  String?   @map("contact_name")
  contactTitle String?   @map("contact_title")
  country      String?
  fax          String?
  homepage     String?
  phone        String?
  postalCode   String?   @map("postal_code")
  products     Product[]
  region       String?

  @@map("suppliers")
}

model Territory {
  territory_id         String              @default(cuid()) @id
  employeeTerritories  EmployeeTerritory[]
  region               Region              @map("region_id")
  territoryDescription String              @map("territory_description")

  @@map("territories")
}

model UsState {
  state_id    Int     @id
  stateAbbr   String? @map("state_abbr")
  stateName   String? @map("state_name")
  stateRegion String? @map("state_region")

  @@map("us_states")
}

I run prisma2 lift save --name init (+ confirm that a new .db-file will be created) and prisma2 lift up, then I get this output:

$ prisma2 lift up
🏋️‍ lift up

Datamodel that will initialize the db:

datasource db {
  provider = "sqlite"
  url      = "file:./northwind.db"
}

model Category {
  category_id  Int       @id
  categoryName String    @map("category_name")
  description  String?
  products     Product[]

  @@map("categories")
}

model Customer {
  customer_id  String  @default(cuid()) @id
  address      String?
  city         String?
  companyName  String  @map("company_name")
  contactName  String? @map("contact_name")
  contactTitle String? @map("contact_title")
  country      String?
  // customerCustomerDemo CustomerCustomerDemo[]
  fax          String?
  orders       Order[]
  phone        String?
  postalCode   String? @map("postal_code")
  region       String?

  @@map("customers")
}

// model CustomerCustomerDemo {
//   customer     Customer            @map("customer_id")
//   customerType CustomerDemographic @map("customer_type_id")

//   @@map("customer_customer_demo")
// }

model CustomerDemographic {
  customer_type_id String  @default(cuid()) @id
  // customerCustomerDemo CustomerCustomerDemo[]
  customerDesc     String? @map("customer_desc")

  @@map("customer_demographics")
}

model Employee {
  employee_id         Int                 @id
  address             String?
  birthDate           DateTime?           @map("birth_date")
  city                String?
  country             String?
  // employees           Employee[]
  employeeTerritories EmployeeTerritory[]
  extension           String?
  firstName           String              @map("first_name")
  hireDate            DateTime?           @map("hire_date")
  homePhone           String?             @map("home_phone")
  lastName            String              @map("last_name")
  notes               String?
  orders              Order[]
  photoPath           String?             @map("photo_path")
  postalCode          String?             @map("postal_code")
  region              String?
  reportsTo           Employee?           @map("reports_to")
  title               String?
  titleOfCourtesy     String?             @map("title_of_courtesy")

  @@map("employees")
}

model EmployeeTerritory {
  order_id Int @id

  employee  Employee  @map("employee_id")
  territory Territory @map("territory_id")

  @@map("employee_territories")
}

model Order {
  order_id       Int       @id
  customer       Customer? @map("customer_id")
  employee       Employee? @map("employee_id")
  freight        Float?
  orderDate      DateTime? @map("order_date")
  // orderDetails   OrderDetail[]
  requiredDate   DateTime? @map("required_date")
  shipAddress    String?   @map("ship_address")
  shipCity       String?   @map("ship_city")
  shipCountry    String?   @map("ship_country")
  shipName       String?   @map("ship_name")
  shippedDate    DateTime? @map("shipped_date")
  shipPostalCode String?   @map("ship_postal_code")
  shipRegion     String?   @map("ship_region")
  shipVia        Shipper?  @map("ship_via")

  @@map("orders")
}

// model OrderDetail {
//   /// Multiple ID fields (compound indexes) are not supported
//   // product_id Product @id
//   /// Multiple ID fields (compound indexes) are not supported
//   // order_id   Order   @id
//   discount   Float
//   quantity   Int
//   unitPrice  Float   @map("unit_price")

//   @@map("order_details")
// }

model Product {
  product_id      Int       @id
  category        Category? @map("category_id")
  discontinued    Int
  // orderDetails    OrderDetail[]
  productName     String    @map("product_name")
  quantityPerUnit String?   @map("quantity_per_unit")
  reorderLevel    Int?      @map("reorder_level")
  supplier        Supplier? @map("supplier_id")
  unitPrice       Float?    @map("unit_price")
  unitsInStock    Int?      @map("units_in_stock")
  unitsOnOrder    Int?      @map("units_on_order")

  @@map("products")
}

model Region {
  region_id         Int         @id
  regionDescription String      @map("region_description")
  territories       Territory[]

  @@map("region")
}

model Shipper {
  shipper_id  Int     @id
  companyName String  @map("company_name")
  orders      Order[]
  phone       String?

  @@map("shippers")
}

model Supplier {
  supplier_id  Int       @id
  address      String?
  city         String?
  companyName  String    @map("company_name")
  contactName  String?   @map("contact_name")
  contactTitle String?   @map("contact_title")
  country      String?
  fax          String?
  homepage     String?
  phone        String?
  postalCode   String?   @map("postal_code")
  products     Product[]
  region       String?

  @@map("suppliers")
}

model Territory {
  territory_id         String              @default(cuid()) @id
  employeeTerritories  EmployeeTerritory[]
  region               Region              @map("region_id")
  territoryDescription String              @map("territory_description")

  @@map("territories")
}

model UsState {
  state_id    Int     @id
  stateAbbr   String? @map("state_abbr")
  stateName   String? @map("state_name")
  stateRegion String? @map("state_region")

  @@map("us_states")
}

Database Changes:

Migration            Database actions            Status

20190927101335-init  12 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
Wrote failed-migrationProgress-20190927101409.md with debugging information.
Please put that file into a gist and post it in Slack.
1. cat failed-migrationProgress-20190927101409.md | pbcopy
2. Create a gist https://gist.github.com/new
Error: Error in migration engine: thread 'tokio-runtime-worker-3' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorCollection { errors: [ModelValidationError { message: "Ambiguous self relation detected.", model_name: "Employee", span: Span { start: 968, end: 1007 } }] }', src/libcore/result.rs:999:5
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: migration_engine::main::{{closure}}
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::continue_panic_fmt
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::result::unwrap_failed
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   9: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  10: <sql_migration_connector::sql_migration_persistence::SqlMigrationPersistence as migration_connector::migration_persistence::MigrationPersistence>::by_name
  11: <migration_engine::api::MigrationApi<C,D> as migration_engine::api::GenericApi>::migration_progress
  12: migration_engine::api::rpc::RpcApi::create_sync_handler
  13: tokio_executor::enter::exit
  14: tokio_threadpool::blocking::blocking
  15: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  16: futures::future::chain::Chain<A,B,C>::poll
  17: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  18: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  19: futures::future::chain::Chain<A,B,C>::poll
  20: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  21: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  22: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  23: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  24: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll
  25: <futures::stream::and_then::AndThen<S,F,U> as futures::stream::Stream>::poll
  26: <futures::stream::forward::Forward<T,U> as futures::future::Future>::poll
  27: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  28: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll
  29: futures::task_impl::std::set
  30: std::panicking::try::do_call
  31: __rust_maybe_catch_panic
  32: tokio_threadpool::task::Task::run
  33: tokio_threadpool::worker::Worker::run_task
  34: tokio_threadpool::worker::Worker::run
  35: std::thread::local::LocalKey<T>::with
  36: std::thread::local::LocalKey<T>::with
  37: tokio_reactor::with_default
  38: tokio::runtime::threadpool::builder::Builder::build::{{closure}}
  39: std::thread::local::LocalKey<T>::with
  40: std::thread::local::LocalKey<T>::with
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This is the generated error file failed-migrationProgress-TIMESTAMP:

Failed migrationProgress at 2019-09-27T08:14:09.699Z

RPC One-Liner

{"id":4,"jsonrpc":"2.0","method":"migrationProgress","params":{"projectInfo":"","migrationId":"20190927101335-init","sourceConfig":"datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./northwind.db\"\n}\n\nmodel Category {\n  category_id  Int       @id\n  categoryName String    @map(\"category_name\")\n  description  String?\n  products     Product[]\n\n  @@map(\"categories\")\n}\n\nmodel Customer {\n  customer_id  String  @default(cuid()) @id\n  address      String?\n  city         String?\n  companyName  String  @map(\"company_name\")\n  contactName  String? @map(\"contact_name\")\n  contactTitle String? @map(\"contact_title\")\n  country      String?\n  // customerCustomerDemo CustomerCustomerDemo[]\n  fax          String?\n  orders       Order[]\n  phone        String?\n  postalCode   String? @map(\"postal_code\")\n  region       String?\n\n  @@map(\"customers\")\n}\n\n// model CustomerCustomerDemo {\n//   customer     Customer            @map(\"customer_id\")\n//   customerType CustomerDemographic @map(\"customer_type_id\")\n\n//   @@map(\"customer_customer_demo\")\n// }\n\nmodel CustomerDemographic {\n  customer_type_id String  @default(cuid()) @id\n  // customerCustomerDemo CustomerCustomerDemo[]\n  customerDesc     String? @map(\"customer_desc\")\n\n  @@map(\"customer_demographics\")\n}\n\nmodel Employee {\n  employee_id         Int                 @id\n  address             String?\n  birthDate           DateTime?           @map(\"birth_date\")\n  city                String?\n  country             String?\n  // employees           Employee[]\n  employeeTerritories EmployeeTerritory[]\n  extension           String?\n  firstName           String              @map(\"first_name\")\n  hireDate            DateTime?           @map(\"hire_date\")\n  homePhone           String?             @map(\"home_phone\")\n  lastName            String              @map(\"last_name\")\n  notes               String?\n  orders              Order[]\n  photoPath           String?             @map(\"photo_path\")\n  postalCode          String?             @map(\"postal_code\")\n  region              String?\n  reportsTo           Employee?           @map(\"reports_to\")\n  title               String?\n  titleOfCourtesy     String?             @map(\"title_of_courtesy\")\n\n  @@map(\"employees\")\n}\n\nmodel EmployeeTerritory {\n  order_id Int @id\n\n  employee  Employee  @map(\"employee_id\")\n  territory Territory @map(\"territory_id\")\n\n  @@map(\"employee_territories\")\n}\n\nmodel Order {\n  order_id       Int       @id\n  customer       Customer? @map(\"customer_id\")\n  employee       Employee? @map(\"employee_id\")\n  freight        Float?\n  orderDate      DateTime? @map(\"order_date\")\n  // orderDetails   OrderDetail[]\n  requiredDate   DateTime? @map(\"required_date\")\n  shipAddress    String?   @map(\"ship_address\")\n  shipCity       String?   @map(\"ship_city\")\n  shipCountry    String?   @map(\"ship_country\")\n  shipName       String?   @map(\"ship_name\")\n  shippedDate    DateTime? @map(\"shipped_date\")\n  shipPostalCode String?   @map(\"ship_postal_code\")\n  shipRegion     String?   @map(\"ship_region\")\n  shipVia        Shipper?  @map(\"ship_via\")\n\n  @@map(\"orders\")\n}\n\n// model OrderDetail {\n//   /// Multiple ID fields (compound indexes) are not supported\n//   // product_id Product @id\n//   /// Multiple ID fields (compound indexes) are not supported\n//   // order_id   Order   @id\n//   discount   Float\n//   quantity   Int\n//   unitPrice  Float   @map(\"unit_price\")\n\n//   @@map(\"order_details\")\n// }\n\nmodel Product {\n  product_id      Int       @id\n  category        Category? @map(\"category_id\")\n  discontinued    Int\n  // orderDetails    OrderDetail[]\n  productName     String    @map(\"product_name\")\n  quantityPerUnit String?   @map(\"quantity_per_unit\")\n  reorderLevel    Int?      @map(\"reorder_level\")\n  supplier        Supplier? @map(\"supplier_id\")\n  unitPrice       Float?    @map(\"unit_price\")\n  unitsInStock    Int?      @map(\"units_in_stock\")\n  unitsOnOrder    Int?      @map(\"units_on_order\")\n\n  @@map(\"products\")\n}\n\nmodel Region {\n  region_id         Int         @id\n  regionDescription String      @map(\"region_description\")\n  territories       Territory[]\n\n  @@map(\"region\")\n}\n\nmodel Shipper {\n  shipper_id  Int     @id\n  companyName String  @map(\"company_name\")\n  orders      Order[]\n  phone       String?\n\n  @@map(\"shippers\")\n}\n\nmodel Supplier {\n  supplier_id  Int       @id\n  address      String?\n  city         String?\n  companyName  String    @map(\"company_name\")\n  contactName  String?   @map(\"contact_name\")\n  contactTitle String?   @map(\"contact_title\")\n  country      String?\n  fax          String?\n  homepage     String?\n  phone        String?\n  postalCode   String?   @map(\"postal_code\")\n  products     Product[]\n  region       String?\n\n  @@map(\"suppliers\")\n}\n\nmodel Territory {\n  territory_id         String              @default(cuid()) @id\n  employeeTerritories  EmployeeTerritory[]\n  region               Region              @map(\"region_id\")\n  territoryDescription String              @map(\"territory_description\")\n\n  @@map(\"territories\")\n}\n\nmodel UsState {\n  state_id    Int     @id\n  stateAbbr   String? @map(\"state_abbr\")\n  stateName   String? @map(\"state_name\")\n  stateRegion String? @map(\"state_region\")\n\n  @@map(\"us_states\")\n}"}}

RPC Input Readable

{
  "id": 4,
  "jsonrpc": "2.0",
  "method": "migrationProgress",
  "params": {
    "projectInfo": "",
    "migrationId": "20190927101335-init",
    "sourceConfig": "datasource db {\n  provider = \"sqlite\"\n  url      = \"file:./northwind.db\"\n}\n\nmodel Category {\n  category_id  Int       @id\n  categoryName String    @map(\"category_name\")\n  description  String?\n  products     Product[]\n\n  @@map(\"categories\")\n}\n\nmodel Customer {\n  customer_id  String  @default(cuid()) @id\n  address      String?\n  city         String?\n  companyName  String  @map(\"company_name\")\n  contactName  String? @map(\"contact_name\")\n  contactTitle String? @map(\"contact_title\")\n  country      String?\n  // customerCustomerDemo CustomerCustomerDemo[]\n  fax          String?\n  orders       Order[]\n  phone        String?\n  postalCode   String? @map(\"postal_code\")\n  region       String?\n\n  @@map(\"customers\")\n}\n\n// model CustomerCustomerDemo {\n//   customer     Customer            @map(\"customer_id\")\n//   customerType CustomerDemographic @map(\"customer_type_id\")\n\n//   @@map(\"customer_customer_demo\")\n// }\n\nmodel CustomerDemographic {\n  customer_type_id String  @default(cuid()) @id\n  // customerCustomerDemo CustomerCustomerDemo[]\n  customerDesc     String? @map(\"customer_desc\")\n\n  @@map(\"customer_demographics\")\n}\n\nmodel Employee {\n  employee_id         Int                 @id\n  address             String?\n  birthDate           DateTime?           @map(\"birth_date\")\n  city                String?\n  country             String?\n  // employees           Employee[]\n  employeeTerritories EmployeeTerritory[]\n  extension           String?\n  firstName           String              @map(\"first_name\")\n  hireDate            DateTime?           @map(\"hire_date\")\n  homePhone           String?             @map(\"home_phone\")\n  lastName            String              @map(\"last_name\")\n  notes               String?\n  orders              Order[]\n  photoPath           String?             @map(\"photo_path\")\n  postalCode          String?             @map(\"postal_code\")\n  region              String?\n  reportsTo           Employee?           @map(\"reports_to\")\n  title               String?\n  titleOfCourtesy     String?             @map(\"title_of_courtesy\")\n\n  @@map(\"employees\")\n}\n\nmodel EmployeeTerritory {\n  order_id Int @id\n\n  employee  Employee  @map(\"employee_id\")\n  territory Territory @map(\"territory_id\")\n\n  @@map(\"employee_territories\")\n}\n\nmodel Order {\n  order_id       Int       @id\n  customer       Customer? @map(\"customer_id\")\n  employee       Employee? @map(\"employee_id\")\n  freight        Float?\n  orderDate      DateTime? @map(\"order_date\")\n  // orderDetails   OrderDetail[]\n  requiredDate   DateTime? @map(\"required_date\")\n  shipAddress    String?   @map(\"ship_address\")\n  shipCity       String?   @map(\"ship_city\")\n  shipCountry    String?   @map(\"ship_country\")\n  shipName       String?   @map(\"ship_name\")\n  shippedDate    DateTime? @map(\"shipped_date\")\n  shipPostalCode String?   @map(\"ship_postal_code\")\n  shipRegion     String?   @map(\"ship_region\")\n  shipVia        Shipper?  @map(\"ship_via\")\n\n  @@map(\"orders\")\n}\n\n// model OrderDetail {\n//   /// Multiple ID fields (compound indexes) are not supported\n//   // product_id Product @id\n//   /// Multiple ID fields (compound indexes) are not supported\n//   // order_id   Order   @id\n//   discount   Float\n//   quantity   Int\n//   unitPrice  Float   @map(\"unit_price\")\n\n//   @@map(\"order_details\")\n// }\n\nmodel Product {\n  product_id      Int       @id\n  category        Category? @map(\"category_id\")\n  discontinued    Int\n  // orderDetails    OrderDetail[]\n  productName     String    @map(\"product_name\")\n  quantityPerUnit String?   @map(\"quantity_per_unit\")\n  reorderLevel    Int?      @map(\"reorder_level\")\n  supplier        Supplier? @map(\"supplier_id\")\n  unitPrice       Float?    @map(\"unit_price\")\n  unitsInStock    Int?      @map(\"units_in_stock\")\n  unitsOnOrder    Int?      @map(\"units_on_order\")\n\n  @@map(\"products\")\n}\n\nmodel Region {\n  region_id         Int         @id\n  regionDescription String      @map(\"region_description\")\n  territories       Territory[]\n\n  @@map(\"region\")\n}\n\nmodel Shipper {\n  shipper_id  Int     @id\n  companyName String  @map(\"company_name\")\n  orders      Order[]\n  phone       String?\n\n  @@map(\"shippers\")\n}\n\nmodel Supplier {\n  supplier_id  Int       @id\n  address      String?\n  city         String?\n  companyName  String    @map(\"company_name\")\n  contactName  String?   @map(\"contact_name\")\n  contactTitle String?   @map(\"contact_title\")\n  country      String?\n  fax          String?\n  homepage     String?\n  phone        String?\n  postalCode   String?   @map(\"postal_code\")\n  products     Product[]\n  region       String?\n\n  @@map(\"suppliers\")\n}\n\nmodel Territory {\n  territory_id         String              @default(cuid()) @id\n  employeeTerritories  EmployeeTerritory[]\n  region               Region              @map(\"region_id\")\n  territoryDescription String              @map(\"territory_description\")\n\n  @@map(\"territories\")\n}\n\nmodel UsState {\n  state_id    Int     @id\n  stateAbbr   String? @map(\"state_abbr\")\n  stateName   String? @map(\"state_name\")\n  stateRegion String? @map(\"state_region\")\n\n  @@map(\"us_states\")\n}"
  }
}

Stack Trace

Error in migration engine: thread 'tokio-runtime-worker-3' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorCollection { errors: [ModelValidationError { message: "Ambiguous self relation detected.", model_name: "Employee", span: Span { start: 968, end: 1007 } }] }', src/libcore/result.rs:999:5
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: migration_engine::main::{{closure}}
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::continue_panic_fmt
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::result::unwrap_failed
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   9: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  10: <sql_migration_connector::sql_migration_persistence::SqlMigrationPersistence as migration_connector::migration_persistence::MigrationPersistence>::by_name
  11: <migration_engine::api::MigrationApi<C,D> as migration_engine::api::GenericApi>::migration_progress
  12: migration_engine::api::rpc::RpcApi::create_sync_handler
  13: tokio_executor::enter::exit
  14: tokio_threadpool::blocking::blocking
  15: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  16: futures::future::chain::Chain<A,B,C>::poll
  17: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  18: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
  19: futures::future::chain::Chain<A,B,C>::poll
  20: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
  21: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  22: <futures::future::either::Either<A,B> as futures::future::Future>::poll
  23: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  24: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll
  25: <futures::stream::and_then::AndThen<S,F,U> as futures::stream::Stream>::poll
  26: <futures::stream::forward::Forward<T,U> as futures::future::Future>::poll
  27: <futures::future::map::Map<A,F> as futures::future::Future>::poll
  28: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll
  29: futures::task_impl::std::set
  30: std::panicking::try::do_call
  31: __rust_maybe_catch_panic
  32: tokio_threadpool::task::Task::run
  33: tokio_threadpool::worker::Worker::run_task
  34: tokio_threadpool::worker::Worker::run
  35: std::thread::local::LocalKey<T>::with
  36: std::thread::local::LocalKey<T>::with
  37: tokio_reactor::with_default
  38: tokio::runtime::threadpool::builder::Builder::build::{{closure}}
  39: std::thread::local::LocalKey<T>::with
  40: std::thread::local::LocalKey<T>::with
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
nikolasburk commented 5 years ago

Update: I tried removing the reportsTo and employees self relation fields on Employee and deleted the DB file. Now the migration is going through.

divyenduz commented 5 years ago

This looks like a duplicate of https://github.com/prisma/prisma2/issues/488 Which has a smaller reproduction.

@nikolasburk if you think so too, please feel free to close this one.