Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kotaitos opened this issue Jan 13, 2023 · 0 comments
Open

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

kotaitos opened this issue Jan 13, 2023 · 0 comments

Comments

@kotaitos
Copy link

kotaitos commented Jan 13, 2023

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]
@kotaitos kotaitos changed the title If the @relation part in the .prisma file is changed as follows, a syntax error occurs in @relation in the generated schema.prisma. Problem occurring in @relation part when generating schema.prisma Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant