Pg: Inserting new data with auto increment column

I am getting error while inserting data to postgres from nextjs api. Error: detail: 'Key (id)=(21) already exists.',
I have table with three columns and the API is submitting values as name and status. I am guessing postgres would take care of auto increment. what is the issue here ?
    id: serial('id').primaryKey(),
    name: varchar('name', { length: 256 }).notNull(),
    status: varchar('status', { length: 100 }).notNull().default('DRAFT')

API
 const res = await db.insert(dashboards)
            .values({ ...json, status: 'DRAFT' }).returning({ id: dashboards.id })
        return NextResponse.json(res, { status: 200 })
Was this page helpful?