Problem
As per documentation @updatedAt is "Implemented at Prisma level" which implies server time, whereas for createdAt I would use "@default(now())" which uses database time.
The infrastructure Prisma code is running on (let's say servers for simplicity) may not have the time synced with the DB (NTP server may not be employed, etc) and the servers (if say web farm) may not be synced with themselves. This would result in times landing on DB which do not portray an accurate sequence.
Suggested solution
add an option to @updatedAt to use DB time. Something like @updatedAt(now()) which would signal the use of database time (ie CURRENT_TIMESTAMP) when setting the field value.
Alternatives
For now, I'm setting the value via ON BEFORE UPDATE trigger which requires manually altering migration files to add the trigger code
Additional context
Thank you!!
Problem
As per documentation
@updatedAtis "Implemented at Prisma level" which implies server time, whereas forcreatedAtI would use "@default(now())" which uses database time.The infrastructure Prisma code is running on (let's say servers for simplicity) may not have the time synced with the DB (NTP server may not be employed, etc) and the servers (if say web farm) may not be synced with themselves. This would result in times landing on DB which do not portray an accurate sequence.
Suggested solution
add an option to
@updatedAtto use DB time. Something like@updatedAt(now())which would signal the use of database time (ieCURRENT_TIMESTAMP) when setting the field value.Alternatives
For now, I'm setting the value via
ON BEFORE UPDATEtrigger which requires manually altering migration files to add the trigger codeAdditional context
Thank you!!