Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timestamp without change on update

Tags:

mysql

In mysql I have a timestamp with the field name added_on. I created that for a table of leads for a crm. But it's getting updated whenever I update a lead. I only want the timestamp to show only the added time. I dont want that to get updated everytime when I update or make changed in the lead.

Note: while creating the timestamp field i gave default value as timestamp and it shows ON UPDATE CURRENT_TIMESTAMP in the extras field after creating the field.

any ideas to stop the timestamp getting updated whenever I update the row?

like image 773
Bala Avatar asked Nov 15 '11 05:11

Bala


1 Answers

The issue is the ON UPDATE CURRENT_TIMESTAMP. You should be able to undo this behavior with an alter statement like this (not sure what your table name is):

ALTER TABLE leads MODIFY added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
like image 56
Adam Wagner Avatar answered Oct 29 '22 13:10

Adam Wagner