Created
February 5, 2013 08:51
-
-
Save mauroartizzu/4713133 to your computer and use it in GitHub Desktop.
Revisions
-
mauroartizzu created this gist
Feb 5, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ALTER TABLE xxxxxx ADD created_at TIMESTAMP DEFAULT '0000-00-00 00:00:00', ADD updated_at TIMESTAMP DEFAULT '0000-00-00 00:00:00'; CREATE TRIGGER xxxxxx_create BEFORE INSERT ON `xxxxxx` FOR EACH ROW SET NEW.created_at = NOW(), NEW.updated_at = NOW(); CREATE TRIGGER xxxxxx_update BEFORE UPDATE ON `xxxxxx` FOR EACH ROW SET NEW.updated_at = NOW(), NEW.created_at = OLD.created_at;