Use database triggers instead of engine-level code for @updatedAt
#6772
Labels
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/feature
A request for a new feature.
topic: database triggers
topic: schema
topic: updatedAt
Problem
Would be nice if while migrating, prisma generates a trigger for
@updatedAt
fields, this way if accessing the db with something other than prisma, we get the same behavior.Suggested solution
From this
to this
Note that this solution is for pgsql only!
But triggers are available in sqlite/mysql/postgresql
IF for any reasons something like
moddatetime
doesn't exist in other databases (mysql/sqlite) then we can resort to the engine-levelupdatedAt
Alternatives
Keep using
@updatedAt
and manually adding the triggers by yourself to each table created by prisma.Additional context
Wanted to add records from another tool (graphile) and found out that I needed the
updatedAt
field to be updated on the database level.The text was updated successfully, but these errors were encountered: