rreeee
Saya mendapat ralat ID kunci asing. Saya menambah beberapa tempoh pajakan dan selepas membuat lebih banyak, saya mendapat ralat ini tetapi ID ditambah secara automatik. Saya mencuba kaedah yang berbeza dalam talian tetapi tidak menemui penyelesaian. Masalahnya ialah ia berlaku sekali juga, tetapi saya menyegarkan pangkalan data dan selepas beberapa lama ia berlaku lagi.
Saya cuba memasukkan kod untuk tempoh pajakan baharu:
model Renting_Units { id Int @id @default(autoincrement()) name String @unique(map: "name") @db.VarChar(255) description String? @db.VarChar(255) createdAt DateTime @default(now()) @db.DateTime(0) updatedAt DateTime @default(now()) @db.DateTime(0) User Users @relation(fields: [id], references: [id]) created_by Int Renting_Periods Renting_Periods[] } model Renting_Periods { id Int @id @default(autoincrement()) product_id Int @db.Int Products Products @relation(fields: [product_id], references: [id], onUpdate: Cascade, onDelete: Cascade) start_date DateTime @db.DateTime(0) end_date DateTime @db.DateTime(0) createdAt DateTime @default(now()) @db.DateTime(0) updatedAt DateTime @default(now()) @db.DateTime(0) renting_unit Int @db.Int Renting_Units Renting_Units @relation(fields: [renting_unit], references: [id], onUpdate: Cascade, onDelete: Cascade) User Users @relation(fields: [id], references: [id]) created_by Int Invoices Invoices[] }
Anda cuba menambah
Product
或Renting_Units
模型连接到renting_Periods
模型,但您引用的 ID 并未引用Product
或Renting_Units
模型。该 ID 可能指其他内容,但当您使用的 ID 对于您尝试执行的操作无效(在本例中连接Product
或Renting_Units
).