Hi there, I'm trying to migrate my prisma-1 servic...
# prisma-client
m
Hi there, I'm trying to migrate my prisma-1 service with nexus and mongodb to prisma2. One odd thing seems to be that with prisma2 you have to add relations to a non-relational database, which wasn't the case in prisma1. Example: model in prisma1:
Copy code
type Email @db(name: "emails") {
    id: ID! @id
    name: String @unique
    emailMessage: EmailMessage
    emailSubject: EmailSubject
    receiverGroup: [Receiver]
    isActivated: Boolean! @default(value: true)
    role: String
    btnName: String
}

type EmailMessage @embedded {
    id: ID! @id
    messageDe: String
    messageEn: String
}

type EmailSubject @embedded {
    id: ID! @id
    subjectDe: String
    subjectEn: String
}

type Receiver @embedded {
    id: ID! @id
    email: String!
    firstName: String
    lastName: String
}
This is working perfectly fine with prisma1 (prisma-client-lib 1.34.5). Due to restrictions by nexus-plugin-prisma I'm bound to prisma version 2.23.0 regarding upgrade. With this version I can't use the model as it is, I have to add relation keys to all models (formerly types) listed. Prisma1 seems to be able to handle this internally without secondary keys. How can I achieve this with prisma2 and mongodb ?
j
I’m unsure what to recommend you about
nexus-plugin-prisma
Here is the official upgrade Guide to migrate from the Prisma 1 MongoDB Beta to MongoDB on Prisma 3.12.0 and later. https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/upgrade-from-mongodb-beta Note that Preview support for Embedded documents were added in 3.10.0 And that the MongoDB connector went GA, Generally Available in 3.12.0 So using 3.12.0 or later seems like the best thing to do
m
@Joël: I have to use nexus-plugin-prisma and therefore am bound to prisma 2.23.0. Nexus-plugin-prisma is incompatible with prisma versions >2.23.x. We are using this in production and nexus-prisma is not in a state for being used in a production environment. Thank you for the hints, but I need a way to fix this with prisma 2.23.0. ;)
@Joël I tried updating with prisma 3.12, but I get strange errors regarding schema keyword. Part of the model:
Copy code
model EmailMessage @embedded {
  id String @id @map("_id") @db.ObjectId
  messageDe String
  messageEn String
}
results in an error running generate
Copy code
Error validating: This line is invalid. It does not start with any known Prisma schema keyword.
model EmailMessage @embedded {
...
model is a schema keyword, isn't it ?
@embedded
seems to be causing the problem