Invalid default value when using defaultNow()

Receiving error:
Invalid default value for 'updated_at' (errno 1067) (sqlstate 42000) (CallerID: 2ga5bxx7mhtso265npy7): Sql: "alter table menus add UNIQUE INDEX menus_public_id_idx (public_id)", BindVars: {REDACTED}`
Invalid default value for 'updated_at' (errno 1067) (sqlstate 42000) (CallerID: 2ga5bxx7mhtso265npy7): Sql: "alter table menus add UNIQUE INDEX menus_public_id_idx (public_id)", BindVars: {REDACTED}`
Seems to happen where there is uniqueindex on table
ASAndrii Sherman5/1/2023
is it PlanetScale?
Yes Any updates on this?
ASAndrii Sherman5/4/2023
Yeah, sorry Could you please explain steps to reproduce? Does this error happen in insert/select? Or do you see it while running migrations?
It happens on drizzle-push. If I have defaultNow() on one of the columns, it starts to complain when I am trying to add indexes or push another update Not sure if this is somethikng on Planetscales side? Intersseing someone having similar issue here without Drizzle This seems to solve it So it seems like it was some sort of PlanetScale issue
ASAndrii Sherman5/5/2023
Yeah, so the case is that PlanetScale have some issues with using default (now()) I would suggest using
For “default now” with PlanetScale Try to regenerate table with this default and then it should work properly We will add .defaultCurrentTimestamp() for PlanetScale cases
Facing the same issue, when will defaultCurrentTimestamp() be released? I'll try the suggested solution in the meantime and submit a PR to the docs repo about this. CURRENT_TIMESTAMP did not work for me i just get
vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'createdAt'
vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'createdAt'
Adding (3) aka my fsp after CURRENT_TIMESTAMP fixed the issue with default I found this issue regarding it but it seems to indicate that there is no workout for onUpdateNow() 😦

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Typesafe floats ?I'm trying to create a column called "weight". It needs to have values like "33.33" as floats. I'm TS Errors in Custom Type citext exampleI want to include citext data type in my postgres schemas. I was delighted to see there's a completeDoes Drizzle support MySQL's LAST_INSERT_ID function?I'm wanting to return a newly created record in the db immediately after a POST. MySQL doesn't suppCheck for empty string in postgresHi. First post. 🙂 Started looking into migrating our project to drizzle today and am loving it so fHow do I set a column to be unique in drizzle syntax for mySQL?Would something like this be correct? ```js export const authUsers = mysqlTable( 'auth_users',How to use JSON field in queryI've already made an issue on GitHub kind of pertaining to this issue, but I don't know if its actuaMySQL, PG proxy driver@Andrii Sherman Hi, Andrew! I noticed that the April milestone for drizzle-orm includes MySQL and PHow to create tables?So my understanding is that running a "migration" means creating the table with the schema in your donUpdateNow usageis onUpdateNow simlar to prisma's @updatedAt ? I.e., updated_at col is auto-updated. If so, is thereUPSERT many ?I have a table called `crmCompanies` containing companies from my client's CRMs. Each day, I recemissing type declarations in mysql-core imports (>v0.25.1)after upgrading drizzle-orm to v0.25.1 i get some errors in my schema telling me that `drizzle-orm/mdrizzle-orm@0.25.0 broke edge supportSeems like the ESM Support broke some stuff in the edge runtime land. This my vercel build output wiDoes Drizzle support type CUID?In Prisma i can use: id String @id @default(cuid()) Do we have similar solutions?Get column name in error messagesIs there a way to get column names exactly where the query is failing, for example when the FOREIGN Using Drizzle as a package in Turborepo doesn't work ?I have a monorepo (Turborepo) with a shared package called @mono/database in which I put my drizzle Argument of type 'Database' is not assignable to parameter of type 'D1Database'.I'm trying to use drizzle with cloudflare d1 but getting this error. Any help?drizzle-zod update schema?is there any plan for `createUpdateSchema` from `drizzle-zod`?How to reproduce a Prisma `include` statement for arrays of related entities without SQL?Hello, I'm trying to translate this SQL query to DrizzleORM; ``` SELECT, channelsmany-to-one selection as arrayHi, Let's say I have a user table, and the user can have multiple profiles. When I select using joiAlias in from() change? (SQLite)Did something change wrt using aliases in `from()`? Until recently I've been using aliases to affect