Applying this schema works as intended (creating a new migration and applying it).
If you comment out all entities (enums & models), create a new migration and apply that, you'll get this error:
Error: Generic("Generic(\"QueryError(Error { kind: Db, cause: Some(DbError { severity: \\\"ERROR\\\", parsed_severity: Some(Error), code: SqlState(\\\"2BP01\\\"), message: \\\"cannot drop table \\\\\\\"WH_Tyre\\\\\\\" because other objects depend on it\\\", detail: Some(\\\"constraint WH_ProductLog_wH_Tyre_fkey on table \\\\\\\"WH_ProductLog\\\\\\\" depends on table \\\\\\\"WH_Tyre\\\\\\\"\\\"), hint: Some(\\\"Use DROP ... CASCADE to drop the dependent objects too.\\\"), position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some(\\\"dependency.c\\\"), line: Some(963), routine: Some(\\\"reportDependentObjects\\\") }) }\\n\\nstack backtrace:\\n 0: backtrace::backtrace::trace::h33eb18a9548cdf19 (0x10583a58e)\\n 1: backtrace::capture::Backtrace::new_unresolved::hbe15ca481078b281 (0x1058387b8)\\n 2: failure::backtrace::internal::InternalBacktrace::new::hf5b4c597dc48a524 (0x105838159)\\n 3: <failure::backtrace::Backtrace as core::default::Default>::default::h41044c97a6cd31c8 (0x105838345)\\n 4: prisma_query::connector::postgres::error::<impl core::convert::From<tokio_postgres::error::Error> for prisma_query::error::Error>::from::he9d24e95339ce652 (0x105372e5c)\\n 5: prisma_query::connector::metrics::query::h5c5ebe96fb4538ac (0x10532ca1e)\\n 6: <prisma_query::connector::postgres::PostgreSql as prisma_query::connector::queryable::Queryable>::query_raw::h2ecab0831ffcf081 (0x10537baad)\\n 7: <sql_migration_connector::migration_database::Mysql as sql_migration_connector::migration_database::MigrationDatabase>::query_raw::he99d7c8874476985 (0x1052b81f8)\\n 8: sql_migration_connector::sql_database_step_applier::SqlDatabaseStepApplier::apply_next_step::h9c9dcd0fca24a8ec (0x10526bdb6)\\n 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::he9750a1d474c9711 (0x10526b808)\\n 10: <migration_connector::migration_applier::MigrationApplierImpl<T> as migration_connector::migration_applier::MigrationApplier<T>>::apply::h88431ebeea6f807b (0x105218dc0)\\n 11: migration_core::commands::apply_migration::ApplyMigrationCommand::handle_migration::h9c03894ed9829d33 (0x1051a76ea)\\n 12: <migration_core::commands::apply_migration::ApplyMigrationCommand as migration_core::commands::command::MigrationCommand>::execute::hfe8163b142bd6dbd (0x1051a6968)\\n 13: <F as jsonrpc_core::calls::RpcMethodSimple>::call::h8fcf08260d2a7d0d (0x1051ee136)\\n 14: <F as jsonrpc_core::calls::RpcMethod<T>>::call::hb442d9b9ed54e562 (0x105197c7c)\\n 15: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::h09a89a2a34fd8553 (0x1051aaeb2)\\n 16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h775f0fa9c81ffc79 (0x105198380)\\n 17: <futures::future::map::Map<A,F> as futures::future::Future>::poll::hcb839739a3f72949 (0x1051b45ef)\\n 18: <futures::future::either::Either<A,B> as futures::future::Future>::poll::hfa9ef8827bc7c312 (0x1051ab1c0)\\n 19: futures::task_impl::std::set::h2cfca3e3b4f1b536 (0x1051e321f)\\n 20: std::thread::local::LocalKey<T>::with::hbfb346743079d794 (0x1051e6e26)\\n 21: futures::future::Future::wait::h1695fef4a3fe94cf (0x1051b42ff)\\n 22: jsonrpc_core::io::IoHandler<M>::handle_request_sync::h0471536d007e7c8b (0x10519269f)\\n 23: migration_core::rpc_api::RpcApi::handle::hfa4c493526d8b375 (0x1051f339b)\\n 24: migration_engine::main::h8411d37c3bce3c55 (0x10516eb3d)\\n 25: std::rt::lang_start::{{closure}}::h056679417669cf3d (0x10516eba6)\\n 26: std::panicking::try::do_call::h1252fc9a2ff235eb (0x10585ea98)\\n 27: __rust_maybe_catch_panic (0x105862e7f)\\n 28: std::rt::lang_start_internal::h4c054360e442146c (0x10585f57e)\\n 29: main (0x10516eb99))\")")
/// 付款 收款
enum Accounting_PayAndGatheringTypeEnum {
PAY
GATHER
}
/// 其他 对公打款 对私打款 承兑 现金
enum Accounting_PaymentTypeEnum {
OTHER
TOPUBLIC
TOPRIVATE
CHENGDUI
CASH
}
model Accounting_Document {
uuid String @default(cuid()) @id
createdAt DateTime @default(now())
documentNO String @unique
issuedDate DateTime
period Accounting_DocumentPeriod?
items Accounting_DocumentItem[]
}
model Accounting_DocumentItem {
uuid String @default(cuid()) @id
borrowerAmountInCent Int
document Accounting_Document
loanerAmountInCent Int
relationUnit Relation_Unit
subject Accounting_Subject
summary String
}
model Accounting_Subject {
uuid String @default(cuid()) @id
number String @unique
cat String
enable Boolean @default(true)
remark String?
searchWord String
subject String
items Accounting_DocumentItem[]
}
model Accounting_DocumentPeriod {
uuid String @default(cuid()) @id
name String @unique
documents Accounting_Document[]
}
model Accounting_PayAndGathering {
uuid String @default(cuid()) @id
createdAt DateTime @default(now())
issuedDate DateTime
payment Accounting_Payment
type Accounting_PayAndGatheringTypeEnum @default(value: GATHER)
}
model WH_Product {
uuid String @default(cuid()) @id
isTyre Boolean
name String @unique
nameForSearch String
storeNumber Int
normalGood BaseInfo_NormalGood?
/// or
tyre BaseInfo_TyrePatternSpec?
logs WH_ProductLog[]
orderInOrderItems Order_InOrderItem[]
orderOutOrderItems Order_OutOrderItem[]
}
model Order_InOrderItem {
uuid String @default(cuid()) @id
number Int
numberPlan Int
orderItem Order_Item
orderProduct WH_Product
remark String
unitPriceINCent Int
}
model Order_Item {
uuid String @default(cuid()) @id
orderInfo Order_Info
orderInOrderItem Order_InOrderItem?
orderOutOrderItem Order_OutOrderItem?
wHProductLog WH_ProductLog[]
}
model Order_Number {
/// id String @default(cuid()) @id
prefix String @id @default(cuid())
count Int
}
model Relation_Employer {
id String @default(cuid()) @id
baseUser Relation_BaseUser
// @id
dingdingID String
joinTime DateTime
relationUnit Relation_Unit
state Relation_EmployerStateEnum @default(value: ONJOB)
inchargeOfDeparts HR_Department[] @relation("inchargeOfDeparts")
belongsToDeparts HR_Department[] @relation("HR_DepartmentStaff")
appliedBusinessApplications Business_Application[]
wroteBusinessApplicationMessages Business_ApplicationMessage[]
createdOrderInfos Order_Info[] @relation("creator")
modifiedOrderInfos Order_Info[] @relation("modifier")
createdDeliveryOrders WH_DeliveryOrder[] @relation("creatorOfDO")
modifiedDeliveryOrders WH_DeliveryOrder[] @relation("modifierOfDO")
asOrderDriverOrders WH_DeliveryOrder[] @relation("WH_DeliveryOrderDriver")
}
model WH_ProductLog {
uuid String @default(cuid()) @id
product WH_Product?
/// tyre WH_Tyre
remark String
createdAt DateTime @default(now())
updatedOn DateTime @updatedAt
orderItem Order_Item
}
model Order_OutOrderItem {
uuid String @default(cuid()) @id
number Int
numberPlan Int
orderItem Order_Item
orderProduct WH_Product?
policyDiscountInCent Int
remark String
unitPriceInCent Int
}
model Order_InOrderInfo {
uuid String @default(cuid()) @id
remark String
orderInfo Order_Info
deliveryState Order_InOrderInfoDeliveryStateEnum @default(value: NORMALINORDER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
state Order_InOrderInfoStateEnum @default(value: NEEDAUDIT)
}
model Order_OutOrderInfo {
uuid String @default(cuid()) @id
customer Relation_Customer
address Relation_CustomerAddress
state Order_OutOrderInfoStateEnum @default(value: NEEDAUDIT)
deliveryState Order_OutOrderInfoDeliveryStateEnum @default(value: NORMALOUTORDER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
orderInfo Order_Info
orderType Order_OutOrderInfoOrderTypeEnum @default(value: SALE)
remark String
}
model Order_Info {
uuid String @default(cuid()) @id
orderNO String @unique
state Order_InfoStateEnum
creator Relation_Employer @relation("creator")
modifier Relation_Employer? @relation("modifier")
orderItems Order_Item[]
factory Relation_Factory?
businessApplications Business_Application[] @relation("Business_ApplicationOrder")
// businessEvents Business_Event[]
orderInOrderInfo Order_InOrderInfo
orderOutOrderInfo Order_OutOrderInfo
}
model Business_ApplicationMessage {
uuid String @default(cuid()) @id
application Business_Application
applicationMessageType Business_ApplicationMessageTypeEnum @default(value: USERGENERATED)
createdAt DateTime @default(now())
message String
writer Relation_Employer
}
model WH_DeliveryOrder {
uuid String @default(cuid()) @id
address Relation_CustomerAddress?
createdAt DateTime @default(now())
deliveryState WH_DeliveryOrderDeliveryStateEnum @default(value: NORMALSENDORDER)
deliveryType WH_DeliveryOrderDeliveryTypeEnum @default(value: SENDBYLOGISTIC)
creatorOfDO Relation_Employer @relation("creatorOfDO")
modifierOfDO Relation_Employer? @relation("modifierOfDO")
drivers Relation_Employer[] @relation("WH_DeliveryOrderDriver")
updatedOn DateTime @updatedAt
}
model Accounting_Payment {
uuid String @default(cuid()) @id
name String
// paymentType Accounting_PaymentType
paymentType Accounting_PaymentTypeEnum @default(value: OTHER)
}
model Relation_Unit {
uuid String @default(cuid()) @id
relation Relation_UnitRelation_Enum
relationBaseUser Relation_BaseUser?
relationCustomer Relation_Customer?
relationEmployer Relation_Employer?
relationFactory Relation_Factory?
relationLogistic Relation_Logistic?
accountingDocumentItems Accounting_DocumentItem[]
}
model Relation_BaseUser {
uuid String @default(cuid()) @id
userType Relation_BaseUserUserTypeEnum @default(value: USER)
createdAt DateTime @default(now())
enabled Boolean @default(true)
name String
nameForSearch String
token Office_UserToken
phone String @unique
pswMD5 String
customer Relation_Customer?
employer Relation_Employer?
specialRelationUnit Relation_Unit
auths HR_Authentication[] @relation("HR_UserAuthentication")
uploadedFiles BaseInfo_File[]
}
model BaseInfo_File {
uuid String @default(cuid()) @id
path String
createdAt DateTime @default(now())
uploader Relation_BaseUser
}
model HR_Authentication {
uuid String @default(cuid()) @id
name String @unique
authedUsers Relation_BaseUser[] @relation("HR_UserAuthentication")
}
model Relation_Customer {
id String @default(cuid()) @id
baseUser Relation_BaseUser
//@id
state Relation_CustomerStateEnum @default(value: OPEN)
wxToken String
area BaseInfo_Area?
customerAddress Relation_CustomerAddress?
customerMoneyPeriod Relation_CustomerMoneyPeriod?
customerQuota Relation_CustomerQuota?
orderOutOrderInfo Order_OutOrderInfo[]
photos BaseInfo_Photo[]
relationUnit Relation_Unit
}
model BaseInfo_Brand {
uuid String @default(cuid()) @id
name String
factory Relation_Factory
patterns BaseInfo_Pattern[]
}
model BaseInfo_NormalGood {
uuid String @default(cuid()) @id
kind BaseInfo_NormalGoodKindEnum @default(value: UNDESIGNATED)
name String
remark String
wHProduct WH_Product
}
model BaseInfo_Pattern {
uuid String @default(cuid()) @id
name String @unique
nameForSearch String
position BaseInfo_TyreInfoPositionEnum @default(value: ALLWHEEL)
brand BaseInfo_Brand
specs BaseInfo_Spec[] @relation("BaseInfo_TyrePatternSpec")
photos BaseInfo_Photo[] @relation("BaseInfo_PhotoPattern")
tyrePatternSpecs BaseInfo_TyrePatternSpec[]
}
model BaseInfo_Spec {
uuid String @default(cuid()) @id
name String
nameForSearch String
kind BaseInfo_SpecKindEnum @default(value: UNDESIGNATED)
patterns BaseInfo_Pattern[] @relation("BaseInfo_TyrePatternSpec")
tyrePatternSpecs BaseInfo_TyrePatternSpec[]
}
model BaseInfo_TyrePatternSpec {
uuid String @default(cuid()) @id
pattern BaseInfo_Pattern
spec BaseInfo_Spec
nameForSearch String
warrantyMonth Int
info BaseInfo_TyreInfo?
whProducts WH_Product[]
wHTyre WH_Tyre[]
// @@unique([spec, pattern])
}
model BaseInfo_Photo {
uuid String @default(cuid()) @id
title String
file BaseInfo_File
latitude String
longitude String
customers Relation_Customer
patterns BaseInfo_Pattern[] @relation("BaseInfo_PhotoPattern")
}
model HR_Department {
uuid String @default(cuid()) @id
name String
chief Relation_Employer? @relation("inchargeOfDeparts")
staffs Relation_Employer[] @relation("HR_DepartmentStaff")
}
model Relation_CustomerMoneyPeriod {
uuid String @default(cuid()) @id
paybackDay Int
periodDay Int
periodMonth Int
customer Relation_Customer
}
model Relation_CustomerQuota {
uuid String @default(cuid()) @id
quotaInCent Int
customer Relation_Customer
}
model Relation_CustomerAddress {
uuid String @default(cuid()) @id
addressDetail String
name String
phone String
remark String
customer Relation_Customer
}
model Relation_Factory {
uuid String @default(cuid()) @id
name String @unique
brands BaseInfo_Brand[]
orderInfos Order_Info[]
relationUnit Relation_Unit
}
model Relation_Logistic {
uuid String @default(cuid()) @id
name String
relationUnit Relation_Unit
state Relation_LogisticStateEnum @default(value: COOPERATE)
}
model BaseInfo_Area {
uuid String @default(cuid()) @id
areaCode String @unique
areaName String
latitude String
longitude String
motherAreaCode String
categories BaseInfo_AreaCatagory[] @relation("BaseInfo_AreaAreaCatagory")
customers Relation_Customer[]
}
model BaseInfo_TyreInfo {
uuid String @default(cuid()) @id
depth Int
width Int
tyre BaseInfo_TyrePatternSpec
}
model Business_Application {
uuid String @default(cuid()) @id
applier Relation_Employer
applicationStatus Business_ApplicationStatusEnum @default(value: DRAFT)
createdAt DateTime @default(now())
updatedOn DateTime @updatedAt
messages Business_ApplicationMessage[]
// events Business_Event[] @relation("Business_ApplicationEvent")
orders Order_Info[] @relation("Business_ApplicationOrder")
}
model BaseInfo_AreaCatagory {
uuid String @default(cuid()) @id
catagoryName String
areas BaseInfo_Area[] @relation("BaseInfo_AreaAreaCatagory")
}
model Office_UserToken {
uuid String @id @default(cuid())
baseUser Relation_BaseUser
//@id
expireDate DateTime
token String
}
model WH_Tyre {
uuid String @default(cuid()) @id
barcode String
tyreNo String
tyrePatternSpec BaseInfo_TyrePatternSpec
applicationStatus WH_TyreApplicationStatusEnum @default(OTHER)
createdAt DateTime @default(now())
updatedOn DateTime @updatedAt
productLogs WH_ProductLog[]
// @@unique([barcode,tyrePatternSpec])
}
/// 其他 未指定 窜货 赠品
enum BaseInfo_NormalGoodKindEnum {
OTHER
UNDESIGNATED
CHUANHUO
GIFT
}
/// 有内全套 有内空壳 未指定 真空
enum BaseInfo_SpecKindEnum {
YOUNEIQUANTAO
YOUNEIKONGKE
UNDESIGNATED
ZHENKONG
}
/// 全轮位 拖车轴 未指定 驱动轴
enum BaseInfo_TyreInfoPositionEnum {
ALLWHEEL
TRAILOR
UNDESIGNATED
DRIVER
}
/// 已落实 待审核 待落实 草稿 驳回
enum Business_ApplicationStatusEnum {
REJECTED
DRAFT
NEED_DONE
NEED_AUDITTING
DONE
}
/// 用户生成 系统生成
enum Business_ApplicationMessageTypeEnum {
USER_GENERATED
SYSTEM_GENERATED
}
/// 正常入库订单 直发订单
enum Order_InOrderInfoDeliveryStateEnum {
NORMAL_IN_ORDER
DIRECT_SEND_ORDER
}
/// 入库完成 取消 待入库 待审核 待录入胎号
enum Order_InOrderInfoStateEnum {
INSTORE_DONE
CANCELED
NEED_INSTORE
NEED_AUDIT
NEED_INPUT_TIRE_NUMBER
}
/// 入库 出库
enum Order_InfoStateEnum {
INSTORE
OUTSTORE
}
/// 正常出库订单 直发订单
enum Order_OutOrderInfoDeliveryStateEnum {
NORMAL_OUT_ORDER
DIRECT_SEND_ORDER
}
/// 三包 退货 销售
enum Order_OutOrderInfoOrderTypeEnum {
SANBAO
SALE
RETURN_GOOD
}
/// 取消 待审核 待出库 待录入胎号 出库完成
enum Order_OutOrderInfoStateEnum {
CANCELED
NEED_AUDIT
NEED_OUTSTORE
NEED_INPUT_TIRE_NUMBER
OUTSTORE_DONE
}
/// 用户 职员
enum Relation_BaseUserUserTypeEnum {
USER
EMPLOYER
}
/// 在职 离职
enum Relation_EmployerStateEnum {
ON_JOB
OFF_JOB
}
/// 销户 在营
enum Relation_CustomerStateEnum {
OPEN
CLOSED
}
/// 其他 厂家 员工 客户 承兑商 物流
enum Relation_UnitRelation_Enum {
OTHER
FACTORY
EMPLOYER
CUSTOMER
LOGISTIC
CHENGDUIOR
}
/// 合作 禁止合作
enum Relation_LogisticStateEnum {
COOPERATE
FORBIDEN
}
/// 正常送货单 直发订单
enum WH_DeliveryOrderDeliveryStateEnum {
NORMALSENDORDER
DIRECTSENDORDER
}
/// 物流发货 货车送货
enum WH_DeliveryOrderDeliveryTypeEnum {
SENDBYLOGISTIC
SENDBYCAR
}
/// 其他 在库 已出库 未入库
enum WH_TyreApplicationStatusEnum {
OTHER
INWHAREHOUSE
OUTWAREHOUSE
NOTYETWAREHOUSE
}
We won't act on this in this week as it's a bigger refactoring.
Not sure if this was resolved, but I am facing the same issue on my end when I was trying to drop a table including all its relations. Screenshot below. Using the latest alpha of migrate

Report ID: 3067
If that does not suffice, please let me know and I can privately send you the migration folder.
@tvvignesh it should be fixed in alpha 1060 (see this PR: https://github.com/prisma/prisma-engines/pull/662)
If could confirm it works now, that would be super helpful :)
@tomhoule Oops. I dropped the tables, reset everything and ran the migrations to get over this. Will see if I can reproduce it again somehow.
@tomhoule Just tested it with the latest alpha and it works. Great work :+1:

I am currently facing this same issue using Beta.3. Any fix apart from using the latest alpha?
@martineboh You can upgrade the latest beta version, this change should be included in that release.
I see this was fixed in beta.4 and I'm using 2.1.1 but I'm still getting this bug when trying to run migrate

Hm, can you please open a new issue with a reproduction? Also, try using a fresh database once
Most helpful comment
@tomhoule Just tested it with the latest alpha and it works. Great work :+1: