© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
Emirhan

How to update "updated_at" column automaticly when related row is updated?

Hello.

I'm using PostgreSQL as a dbms. So driver is pg. I want to update the "updated_at" column when the row is updated.

Is this implementation is ok for the feature.

const updated_at = timestamp("updated_at")
  .notNull()
  .defaultNow()
  .$onUpdateFn(() => sql`now()`);
const updated_at = timestamp("updated_at")
  .notNull()
  .defaultNow()
  .$onUpdateFn(() => sql`now()`);
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SQLite update at column
Drizzle TeamDTDrizzle Team / help
2y ago
Auto update for updated_at
Drizzle TeamDTDrizzle Team / help
3y ago
updatedAt timestamp update on DB row update
Drizzle TeamDTDrizzle Team / help
3y ago
created_at/updated_at
Drizzle TeamDTDrizzle Team / help
2y ago