docs icon indicating copy to clipboard operation
docs copied to clipboard

Consider expanding error P1012 description

Open andrew-walford-prisma opened this issue 2 years ago • 0 comments

We've had a suggestion to expand our docs for error code P1012 to include invalid schema errors (when parsed with Prisma 4 or later).

Slack thread: https://prisma-company.slack.com/archives/C5Z9TH6N9/p1660549192661239

Example:

  • User has Prisma 3.12.0 with a valid schema
  • User upgrades to Prisma 4.0.0 (or newer) which now considers their schema file to be invalid. Here is an example error;
Error code: P1012
error: Error parsing attribute "@relation": A one-to-one relation must use unique fields on the defining side. Either add an `@unique` attribute to the field `profileId`, or change the relation to one-to-many.
  -->  schema.prisma:14
   | 
13 |   id        Int      @id @default(autoincrement())
14 |   profile   Profile? @relation(fields: [profileId], references: [id])
15 |   profileId Int?

The P1012 section of the docs already contains:

Error parsing attribute @{}: {}

But it might be helpful to direct users to our upgrade guide, because some of these errors are not considered to be errors with all Prisma versions.

andrew-walford-prisma avatar Aug 15 '22 08:08 andrew-walford-prisma