Skip to content

@updatedAt should use database time #9317

@clearwaterstream

Description

@clearwaterstream

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!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions