Drizzle ORM schema not working

Hey all, I have a drizzle orm schema and I can't really understand the error message, could someone please help? its connected to a planetscale db

scheme:
export const timesheets = mysqlTable("timesheets", {
  id: serial("id").primaryKey().autoincrement(),
  work_provider: varchar("work_provider", { length: 128 }),
  date_of_work: timestamp("date_of_work").defaultNow(),
  order_num: varchar("order_num", { length: 128 }).notNull(),
  work_item: varchar("work_item", { length: 128 }).notNull(),
  quantity: serial("quantity").notNull(),
  notes: varchar("notes", { length: 1024 }).notNull(),
  gang_price_split: varchar("gang_price_split", { length: 128 }).notNull(),
  created_at: timestamp("created_at").defaultNow(),
});

export type Timesheet = InferModel<typeof timesheets>;

export const timesheetsRelations = relations(timesheets, ({ many }) => ({
  engineers: many(engineers),
  timesheetsToEngineers: many(timesheetsToEngineers),
}));

export const engineers = mysqlTable("engineers", {
  id: serial("id").primaryKey().autoincrement(),
  firstName: varchar("firstName", { length: 128 }).notNull(),
  lastName: varchar("lastName", { length: 256 }).notNull(),
  birthDate: varchar("birthDate", { length: 32 }).notNull(),
});

export type Engineer = InferModel<typeof engineers>;

export const engineersRelations = relations(engineers, ({ many }) => ({
  timesheets: many(timesheets),
  timesheetsToEngineers: many(timesheetsToEngineers),
}));

export const timesheetsToEngineers = mysqlTable(
  "timesheets_to_engineers",
  {
    engineerId: int("engineer_id")
      .notNull()
      .references(() => engineers.id),
    timesheetId: int("timesheet_id")
      .notNull()
      .references(() => timesheets.id),
  },
  (t) => ({
    pk: primaryKey(t.engineerId, t.timesheetId),
  })
);
Was this page helpful?