prisma1-upgrade icon indicating copy to clipboard operation
prisma1-upgrade copied to clipboard

Prisma 1 Enum scalar lists error out

Open LawJolla opened this issue 5 years ago • 5 comments

For example:

Prisma 1 Data Model

type EmailAddress {
  id: ID! @id
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
  name: String
  email: String!
  user: User @relation(link: INLINE)
  deals: [Deal]
  emailType: [EmailTypeEnum] @default(value: Current) @scalarList(strategy: RELATION)
  emailOwnerEnum: OwnerEnum! @default(value: Buyer)
}
npx prisma introspect
model EmailAddress {
  id                     String                   @default(cuid()) @id
  createdAt              DateTime
  updatedAt              DateTime
  name                   String?
  email                  String
  emailOwnerEnum         String
  user                   String?
  User                   User?                    @relation(fields: [user], references: [id])
  EmailAddress_emailType EmailAddress_emailType[]
  Deal                   Deal[]
}
npx prisma-upgrade
model EmailAddress {
  id                     String                   @default(cuid()) @id
  createdAt              DateTime                 @default(now())
  updatedAt              DateTime                 @updatedAt
  name                   String?
  email                  String
  emailOwnerEnum         String
  userId                 String?                  @map("user")
  user                   User?                    @relation(fields: [user], references: [id])
  EmailAddress_emailType EmailAddress_emailType[]
  deals                  Deal[]
}

Errors out on the EmailAddress_emailType[] Type "EmailAddress_emailType" is neither a built-in type, nor refers to another model, custom type, or enum.

LawJolla avatar Aug 19 '20 21:08 LawJolla

Interesting. Are you running Postgres or MySQL?

matthewmueller avatar Aug 20 '20 08:08 matthewmueller

Postgres. I'll continue poking at it and see if I can move this issue a little more forward. Thanks for your consideration and hard work!

LawJolla avatar Aug 20 '20 17:08 LawJolla

Thanks! This should be possible in Postgres. Figuring out which SQL statement is broken for you and how to fix it would certainly speed things up.

Here's a nice example: https://github.com/prisma/upgrade/issues/75#issuecomment-676746087

matthewmueller avatar Aug 21 '20 11:08 matthewmueller

Type "EmailAddress_emailType" is neither a built-in type, nor refers to another model, custom type, or enum.

What part errors out? The SQL, P1 client, or P2 client?

If it's the generated SQL, which SQL command are you running when it errors out?

matthewmueller avatar Sep 11 '20 08:09 matthewmueller

I experienced this while implementing various fixes in our fork. See https://github.com/reibus/prisma-upgrade/pull/1/files#r894814148

mattkindy avatar Jun 10 '22 18:06 mattkindy