Prisma migration needs default value?

Viewed 2669

I'm having a problem with Prisma data modeling give tried almost everything but i still don't get what this error is giving me. It says that table needs a default value when I already have given it a ID then i tried to remove the relation name same thing happens here my model:

model UserToUser {
id          Int   @id @default(autoincrement())
userId      Int?
follower    User? @relation("follower",fields: [userId], references: [id])
following   User  @relation("following", fields: [followingId], references: [id])
followingId Int  
}

Then it gives me an error saying "Step 2 Added the required column followingId to the UserToUser table without a default value. There are 2 rows in this table, it is not possible to execute this step." How do I fix it?

model User {
id              Int               @id @default(autoincrement())
points          Int               @default(0)
email           String            @unique
password        String
name            String?
posts           Post[]
Profile         Profile?
About           About?
Update          Update[]
Liked           Liked[]
following       UserToUser[] @relation("following")
follower        UserToUser[] @relation("follower")
}
1 Answers

Can you see this example from prisma Docs?

model User {
  id          Int      @id @default(autoincrement())
  name        String?
  followedBy  User[]   @relation("UserFollows", references: [id])
  following   User[]   @relation("UserFollows", references: [id])
}
Related