Unique constraint failed on the fields: (`id`) ERR...
# orm-help
k
Unique constraint failed on the fields: (
id
) ERROR T^T... Do you know how to reset pk?..
Copy code
await prisma.user.deleteMany()
console.log(await prisma.user.findMany()); // []
await prisma.user.create({
      data: {
        id: '123',
      },
    });   // Error
r
@kkangsan πŸ‘‹ You can change the pk of the record that has the
id
123
and then create a new record.
k
ty, Is the existing pk not usable?
r
If it’s already referenced in another record then no.
k
Is there a way to reset the DB table to its initial state?
r
You can reset your database using this.
βœ… 1
πŸ‘€ 1
k
can i use prisma cli in code ??
shell script..? hmm..
r
Only shell. To use it in code, you would need to use something like
exec
.
βœ… 1
k
https://flaviocopes.com/prisma-clear-database/ I found a blog that is struggling with the same problem as me.