Skip to content

Problem occurring in @relation part when generating schema.prisma #222

@kotaitos

Description

@kotaitos

If the @relation part in the .prisma file is changed as follows, a syntax error occurs in @relation in the generated schema.prisma.

  • sample.prisma
    before↓
model Sample {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id])
  employee_id     Int
  ...
}

after↓

model Sample {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id], onDelete: Cascade)
  employee_id     Int
  ...
}
  • schema.prisma
model Employee_Assignment {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
  employee_id     Int
  ...
}

Error

Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: Attribute "@relation" can only be defined once.
  -->  schema.prisma:103
   | 
103 |   employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
   | 
error: Attribute "@relation" can only be defined once.
  -->  schema.prisma:103
   | 
103 |   employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
   | 

Validation Error Count: 2
[Context: getDmmf]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions