0

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?

2
  • "set the udpated_at as the user time" - you mean... instead of grabbing the current date, use the date that was in the existing updated_at column (as a DateTime)? Commented Dec 2, 2014 at 4:53
  • @Peter - not really. I mean, instead of grabbing the date from the DB server, use the date from the API server who made changes on table bar through JDBC/Slick Commented Dec 2, 2014 at 6:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.