Changing `id` type from serial to uuid, causing error.

I'm sorry, I'm new to Drizzle, but I've read through the documentation and discord and cannot find a solution to my problem.

I'm using Next.js 14, Postgresql through Vercel.

When I first started, I built a test UsersTable but now I want to change the
id
from a serial to a uuid. Everytime I try to generate:pg it works, but push:pg fails, giving the following error:

error: column "id" cannot be cast automatically to type uuid
  code: '42804',
  hint: 'You might need to specify "USING id::uuid".',


Could you please tell me how I'm supposed to update my table?

import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"

export const UsersTable = pgTable("users", {
    id: uuid("id").defaultRandom(),
    firstName: varchar("first_name", { length: 50 }).notNull(),
    lastName: varchar("last_name", { length: 50 }).notNull(),
    email: varchar("email", { length: 100 }).notNull().unique(),
    password: varchar("password", { length: 100 }).notNull(),
    createdAt: timestamp("created_at").defaultNow().notNull(),
    updatedAt: timestamp("updated_at").defaultNow().notNull()
})
Was this page helpful?