Created
June 16, 2010 20:45
-
-
Save jimmiw/441240 to your computer and use it in GitHub Desktop.
created_at datetime default now()
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 characters
# If you need to add a created_at field in your database | |
# that inserts "now()" when the insert statement is run, you | |
# can use the following script. | |
# It uses timestamps, but removes the "on update" for the | |
# created_at column, but keeps it on the updated_at (which | |
# needs to update at every change). | |
# | |
# got this snippet here: | |
# http://bugs.mysql.com/bug.php?id=27645 | |
# (search for: "[7 Oct 2009 4:25] Diego Medina") | |
created_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | |
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment