'nsert data after migration make errors using prismaClient

I have a problem that I can't solve. I have this model:

model PermisConduire {
    id             Int     @default(autoincrement()) @id
    noPermis       String   @map("no_permis") @db.VarChar(50)
    dateExpiration DateTime @map("date_expiration") @db.Timestamp(6)
    
    Chauffeur Chauffeur? @relation("permisConduire_chauffeur")
    @@map("permis_conduire")
}

when I migrate the data in my database and then I fill it with an npx prisma db seed, when adding new users with prismaClient using prisma.permisConduire.create() I get the following error on my unique identifier:

return await this.prisma.permisConduire.create

Unique constraint failed on the fields: (id)

On the other hand, when I do a migration in my database without doing any seed to add data to my database during the migration, I have no error in my addition of data with prismaClient and the command prisma.permisConduire.create()

I don't understand why it behaves like this, can you help me?

thank you all for your answers



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source