Browse files

revert setting NOT NULL constraints in add_timestamps

Commit 3dbedd2 added NOT NULL constraints both to table
creation and modification. For creation the new default
makes sense, but the generic situation for changing a
table is that there exist records. Those records have
no creation or modification timestamps, and in the
general case you don't even know them, so when updating
a table these constraints are not going to work. See
a bug report for this use case in #3334.
  • Loading branch information...
1 parent 447d87c commit fcef72890b7f8b974ee490268a48e147bd621253 @fxn fxn committed Mar 2, 2012
@@ -539,8 +539,8 @@ def distinct(columns, order_by)
# ===== Examples
# add_timestamps(:suppliers)
def add_timestamps(table_name)
- add_column table_name, :created_at, :datetime, :null => false
- add_column table_name, :updated_at, :datetime, :null => false
+ add_column table_name, :created_at, :datetime
+ add_column table_name, :updated_at, :datetime
# Removes the timestamp columns (created_at and updated_at) from the table definition.

3 comments on commit fcef728

This doesn't fully revert the original commit. still has this bit of code

options = { :null => false }.merge(args.extract_options!)

so, the default is still NOT NULL.


rafaelfranca replied Jul 16, 2012

True. @davekaro could you open a pull request?

Sure. Here it is - #7095

Please sign in to comment.