Can't add new data to database because of """duplicated id constraint"""

I have a very strange error :

Invalid `db.batch.create()` invocation in
api | /home/alaborde/lisaquapp/api/src/services/batches/batches.ts:21:19
api |
api | 18 }
api | 19
api | 20 export const createBatch: MutationResolvers['createBatch'] = ({ input }) => {
api | → 21 return db.batch.create(
api | Unique constraint failed on the fields: (`id`)

it’s when i call a mutation that is looking like that :

const CREATE_BATCH_MUTATION = gql` 
    mutation CreateBatchMutation($input: CreateBatchInput!) { createBatch(input: $input) {
       id 
    } 
}`

how is that possible ? normally, ID is automatically given to the table by the db (autoincrement)

Ok, i managed to fix my problem.

I was filling my db with a script but some of my db items had a given ID already assigned. I have deleted theses id and reset my db then refilled it with my script. it works now !

3 Likes