prisma / prisma1-upgrade

Prisma 1 Upgrade is a CLI tool to help Prisma 1 users upgrade to Prisma 2.x or newer.
https://www.prisma.io/docs/guides/upgrade-from-prisma-1/how-to-upgrade
Apache License 2.0
51 stars 7 forks source link

Upgrade documentation perhaps could be more clear? #122

Open tobewisebeforeiamold opened 2 years ago

tobewisebeforeiamold commented 2 years ago

I'm attempting to upgrade Prisma from 1 to 2, opting to run prisma1 (1.34.12) along-side Prisma2 (3.4.1)

My problem is that after upgrading the MySQL DB and schema, my prisma1 queries are failing when trying to create nested creates in relation tables.

Example (paraphrased) Prisma2 schema:

model User {
  id     String  @id @default(cuid()) @db.Char(30)
  email  String  @db.MediumText
  admin  Admin?
}
model Admin {
  id     String  @id @default(cuid()) @db.Char(30)
  name   String  @db.MediumText
  userId String  @db.Char(30)
  user   User    @relation(fields: [userId], references: [id], onUpdate: Restrict)
}

Example (paraphrased) Prisma1 query:

mutation ($data: UserCreateInput!) {
  createuser(data: $data) {
    id
    email
  }
}
variables
{
  "data" {
    "email": "diety@supremebeing.org"
    "admin": {
      "create": {
        "name": "me"
      }
    }
  }
}

The (paraphrased) error I get:

(conn=3216) Field 'userId' doesn't have a default value

This section of the schema-incompatibilities prisma-upgrade doc seems to indicate that, after updating the schema and MySQL DB via the directions in the work-around, prisma1 should stick the userId into that Admin table based on the foreign key constraint, shouldn't it?

https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/schema-incompatibilities-postgres#all-non-inline-relations-are-recognized-as-m-n

Should the documentation indicate that 1-N and 1-1 relations will be broken in Prisma1 queries after upgrading to include Prisma2 support, or maybe they are not broken in Prisma1 and I have just set up my schema or MySQL DB incorrectly?

Thank you!