I ran into a very tricky MySQL issue..
Our DB is using type DateTime
for the updated_at
column, and now is too late to change it back to TimeStamp
. I'm thus trying to add a trigger to update this updated_at
column on table changing. The following is what I did:
CREATE TRIGGER foo_schema.bar_datetime_trigger BEFORE UPDATE ON foo_schema.bar
FOR EACH ROW
set NEW.updated_at = NOW();
The NOW()
function here returns the DB time; however, what I actually want is to set the udpated_at
as the user time (Meaning the time of the user who made changes to table bar
). Is it possible to handle this in MySQL?