Invalid default value for timestamp

Ccoldhands3/30/2023
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}
Bbloberenober3/30/2023
@Andrii Sherman
ASAndrii Sherman3/31/2023
If you are using PlanetScale try to change .defaultNow() to
.default(sql`CURRENT_TIMESTAMP`)
ASAndrii Sherman3/31/2023
PlanetScale is restricting (now()) expressions
UUUnknown User3/31/2023
2 Messages Not Public
Sign In & Join Server To View
Bbloberenober3/31/2023
Could you try running the alter column query manually on planetscale to check if it works at all?
UUUnknown User3/31/2023
Message Not Public
Sign In & Join Server To View
LLiltripple_reid4/1/2023
Hey is this error still showing up or have you found a workaround?
UUUnknown User4/1/2023
2 Messages Not Public
Sign In & Join Server To View
Rryanagillie4/3/2023
I had to change it to
.default(sql`CURRENT_TIMESTAMP(3)`)

and for updateNow()
.default(sql`CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)`)
Rryanagillie4/3/2023
but that updateNow is probably really not recommended
Rryanagillie4/3/2023
For some reason planetsale requires CURRENT_TIMESTAMP to be called as a function and not just an interpreted value
Bbloberenober4/3/2023
Weird
We'll probably need to allow customizing the onUpdate value, in addition to onUpdateNow