Overriding MySQL Current_timestamp Default on Update
The MySQL TIMESTAMP data type supports automatic initialization and updating to the current date and time. This can be a convenient way to track when rows are created and modified, but it’s easy to forget about them and have them update data when you don’t want that. In those cases you need to explicitly set the column value to avoid the automatic behavior. On an update, that means setting the column to its current value. Quoting the manual:
If the column is auto-updated, it is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. The column remains unchanged if all other columns are set to their current values. To prevent the column from updating when other columns change, explicitly set it to its current value. To update the column even when other columns do not change, explicitly set it to the value it should have (for example, set it to CURRENT_TIMESTAMP).
For example, say you have a table with a column called mtime that you use to track the last time your application modified each row. If you do a bulk update to that table outside of the application, the mtime column will still be updated even if you don’t want that: