Drizzle TeamDT
Drizzle Team3y ago
14 replies
broly

Invalid default value for timestamp

Hi, I have recently started learning SQL and I've run into this problem with Drizzle Kit. I have this promoCodes table:
// PlanetScale (MySQL) + Drizzle ORM
export const promoCodes = mysqlTable(
  'promo_codes',
  {
    id: serial('id').primaryKey().autoincrement(),
    createdAt: timestamp('created_at').defaultNow(),
    updatedAt: timestamp('updated_at').onUpdateNow(),
    // ...
  }
)
and when I try to push it using
pnpm drizzle-kit push:mysql
, I get this error:
target: xxx.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'updated_at' (errno 1067) (sqlstate 42000) (CallerID: ues4twwhaqs5wh3lm76u): Sql: "alter table promo_codes modify column created_at timestamp default now()", BindVars: {REDACTED}
image.png
Was this page helpful?