9 Replies
you can add the
.onUpdateNow()
call to it.
I'm doing something similar:
It may not be supported by some db providers such as planetscalethis doesn't exist
https://github.com/drizzle-team/drizzle-orm/commit/99df063e2f9c9de1c5090bd920f7bc670415741c it does, make sure you have updated your drizzle packages
im on the latest orm version, still giving type error that it doesnt exist
@.3819
What driver are you using?
Planetscale advices to update these values on app level, because if you use mysql functions like: "NOW()" or "CURRENT_TIMESTAMP()" they will use the mysql server time and timezone. If you want to use the timezone of your own app. set these values at app level.
My Schema TS file:
When creating my record:
When updating:
postgres
beep boop
postgres does not have a feature like that sadly
it can be achieved with triggers, but thats a database layer feature and not really recommended
on the contrary, mysql seems to have some tools to automatically update timestamps
the previously mentioned function
onUpdateNow()
is probably available for mysql only
in order for drizzle to support this for postgres they would have to add a module on top of every insert and pass the date there
personally, i believe adding that into drizzle would sort of defeat the purpose of drizzle as a typesafe orm on top of drivers
the feature does not exist in postgres and drizzle should only provide whatever is available for the database driver youre usingAh ok. Yeah I prefer code first approach. I really don’t like adding triggers or functions I can’t see in my code