`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>


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
}
image.png
Was this page helpful?