Invalid default value for 'updatedAt'
Running into this issue, oddly enough this once worked and now breaks.
16 Replies
Is this for Mysql?
i have the same problem, here is what i did to fixed it
1. copy and drop the entire table(in case you don't have any data yet)
2. paste it back in
3. i suggest copy the created_at and updated_at from this: https://discord.com/channels/1043890932593987624/1142956198488969359/1143601846183800853
ps: this is mysql btw
this is mysql @angelelz
@therealguy_ dropping a table seems a little harsh
Interesting, I just tested the query:
And it worked just fine.
Did you try to generate and push from a schema?
I guess the generated sql would be the same. we are using planetscale btw
Can you show the generated migration?
I'm not a planetscale user but that is correct mysql syntax.
Do you want to try dropping the migration, and delete the fsp value on your schema. just to see the maybe planetscale doesn't support it.
Had this same issue today!
managed to fix it by changing all my
to
seems to be an issue introduced in more recent version, also was very fineky to fix. Had to push an empty schema to a development branch first before pushing the fix
@justhugo I would ask in a separate thread so this one stays on topic.
my bad
no worries, I just want your question answered.
Updating this post, this doesn't work. Trying @iceage2ondvd 's fix next and will update.
timestamp("time").default(sql
current_timestamp())
doesnt work for me.
@iceage2ondvd
I also tried this with no success. Not sure what i'm doing wrong, any thoughts? @angelelz
timestamp("createdAt").defaultNow()
I believe planetscale does not support
.defaultNow()
Try it like this
Again I don't use planetscale, I'm just shooting in the dark hereI tried this:
timestamp("createdAt").default(sql
current_timestamp)
earlier without success..
Oddly enough the push command is failing, but planetscale is registering some of the changes including the createdAt change, but the command is failing so the other schema changes aren't included.So the fix for me was to comment out my whole schema.ts file, push to planetscale (just to drop all the tables), then apply the current_timestamp fix. For some reason this seemed to fix things
if you do this on a seperate branch then you shouldn't have data loss (hopefully)
I recently updated drizzle for the first time in a month, and i think it must have been working at some point because I've been using drizzle in my codebase for a while
maybe im misremembering things
I appreciate the insights thank you, I'll try it out but I don't like the idea of dropping data to fix this.