You basically need both columns to set as timestamps with the default values ββof CURRENT_TIMESTAMP . Unfortunately, this is not allowed in MySQL:
Error Code: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
You cannot have two timestamp columns, although you only need to have the default value of CURRENT_TIMESTAMP and the other is UPDATE CURRENT_TIMESTAMP , this is still not allowed.
Itβs best to specify here:
CREATE TABLE `test` ( `addedDate` dateTime, `lastModified` timestamp on update CURRENT_TIMESTAMP )
Unfortunately, you will have to install the βaddedβ manually insert using the NOW() function.
source share