© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
6 replies
David L. Bowman

`id` type is `undefined` when using `serial("id").primaryKey()`

import { sql } from "drizzle-orm"
import { boolean, pgTable, serial, uuid, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
    id: serial("id").primaryKey(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>
import { sql } from "drizzle-orm"
import { boolean, pgTable, serial, uuid, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
    id: serial("id").primaryKey(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>


Part of the issue is I always have to validate id exists:
"use server"

import { postAuthenticateClient } from "@/lib/telegra/"
import { type User, users } from "@/drizzle/schema"
import { db } from "@/drizzle/db"
import { eq } from "drizzle-orm"

interface PutSetPatientSSOKeyParams {
    id: User["id"]
}

export default async function putSetPatientSSOKey({
    id,
}: PutSetPatientSSOKeyParams) {
   // ...code
    await db
        .update(users)
        .set({
            telegra_sso_key: telegraSSOKey,
        })
        .where(eq(users.id, id))

  // ...code
}
"use server"

import { postAuthenticateClient } from "@/lib/telegra/"
import { type User, users } from "@/drizzle/schema"
import { db } from "@/drizzle/db"
import { eq } from "drizzle-orm"

interface PutSetPatientSSOKeyParams {
    id: User["id"]
}

export default async function putSetPatientSSOKey({
    id,
}: PutSetPatientSSOKeyParams) {
   // ...code
    await db
        .update(users)
        .set({
            telegra_sso_key: telegraSSOKey,
        })
        .where(eq(users.id, id))

  // ...code
}
image.png
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

serial('id').primaryKey() vs primaryKey() in extraConfig?
Drizzle TeamDTDrizzle Team / help
15mo ago
Duplicate indexes when using `serial('').primaryKey()`
Drizzle TeamDTDrizzle Team / help
3y ago
[Turso] Undefined primaryKey on push
Drizzle TeamDTDrizzle Team / help
2y ago