Charity Darko
09/27/2021, 9:10 AMmodel Company {
id Int @id
name String
users User[]
}
model User {
userId Int @default(autoincrement()) @id
companyId Int?
worksAt Company? @relation(fields: [companyId], references: [id])
email String? @unique
name String
password String
@@map(name: "users")
When I run $ prisma db push I get this error. Any assistance will be appreciatedRyan
09/27/2021, 10:06 AMcompanyId field in the database before running db push?Charity Darko
09/27/2021, 10:18 AMmodel Company {
companyId Int @default(autoincrement()) @id
name String
}
model User {
userId Int @default(autoincrement()) @id
companyId Int
email String? @unique
name String
password String
@@map(name: "users")
}
Schema After
model Company {
id Int @id
name String
users User[]
}
model User {
userId Int @default(autoincrement()) @id
companyId Int?
worksAt Company? @relation(fields: [companyId], references: [id])
email String? @unique
name String
password String
@@map(name: "users")
}Ryan
09/27/2021, 10:28 AMcompanyId field and then running db push
2. Manually checking what companyId rows do not match an existing Company and deleting/fixing these.Charity Darko
09/27/2021, 5:22 PM