NeonN
Neon13mo ago
5 replies
thoughtless-moccasin

drizzle uuid troubles

Hello, I am just exploring NextJS finally. I have a drizzle, neon setup. Was originally following a theo.gg tutorial. I am not super versed in postgres or db design tbh. But all the DB's I've worked in use a uuid as the userID for security i guess. However when I try and push up the uuid table I get PostgresError: identity column type must be smallint, integer, or bigint. Can someone help me understand what is going on here? Is this a neon thing? Are UUIDs not good for identifiers? I think I am missing a piece of this puzzle. Here is my table in drizzle:
export const users = createTable(
  "user",
  {
    id: uuid("user_id").primaryKey().defaultRandom(),
    clerkId: varchar("clerk_id", { length: 256 }).notNull(),
    firstName: varchar("first_name", { length: 256 }).notNull(),
    lastName: varchar("last_name", { length: 256 }).notNull(),
    hasImage: boolean("has_image").notNull(),
    imageUrl: varchar("image_url", { length: 256 }),
    createdAt: timestamp("created_at", { withTimezone: true })
      .default(sql`CURRENT_TIMESTAMP`)
      .notNull(),
    updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate(
      () => new Date()
    ),
  },
  (user) => ({
    clerkIdIndex: index("clerk_id_idx").on(user.clerkId),
  })
)
Was this page helpful?