drizzle asks for <table> `id` when doing insert

I guess the ID should be autogenerated by the database itself, but not sure why it's asking me to pass it as a value when doing
  // This throwns TS error saying that ID is missing
  const data = await db.insert(workspaces).values([
    {
      ownerId: session.user.id,
      company: parsed.data.company,
      name: parsed.data.name,
    },
  ]);


using mysql, @planetscale/database
my schemas:
export const workspaces = mysqlTable("workspaces", {
  id: varchar("id", { length: 255 }).primaryKey(),
  name: varchar("name", { length: 255 }).notNull(),
  company: varchar("company", { length: 255 }).notNull(),
  ownerId: varchar("ownerId", { length: 255 }).notNull(),
  createdAt: timestamp("createdAt", { mode: "date" }).notNull().defaultNow(),
});

export const workspacesPickedSchema = createInsertSchema(workspaces)
  .pick({
    name: true,
    company: true,
  })
  .required();
Was this page helpful?