aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-11-20 15:30:46 +0100
committerYves Senn <yves.senn@gmail.com>2014-11-20 15:30:46 +0100
commitd56be864f61cc00eeff27ed42e7cec4194c5347f (patch)
tree82ee21eb30e8de1dc9b7cfc329b6ea5ed34676ea /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
parent7839e27b4e467b5cf94e83555b9b6f0a4f6aaf8a (diff)
downloadrails-d56be864f61cc00eeff27ed42e7cec4194c5347f.tar.gz
rails-d56be864f61cc00eeff27ed42e7cec4194c5347f.tar.bz2
rails-d56be864f61cc00eeff27ed42e7cec4194c5347f.zip
synchronize code and docs for `timestamps` and `add_timestamps`.
This makes the following changes: * warn if `:null` is not passed to `add_timestamps` * `timestamps` method docs link to `add_timestamps` docs * explain where additional options go * adjust examples to include `null: false` (to prevent deprecation warnings)
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index cc86c3776e..7cc5e666af 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -835,11 +835,14 @@ module ActiveRecord
columns
end
- # Adds timestamps (+created_at+ and +updated_at+) columns to the named table.
+ include TimestampDefaultDeprecation
+ # Adds timestamps (+created_at+ and +updated_at+) columns to +table_name+.
+ # Additional options (like <tt>null: false</tt>) are forwarded to #add_column.
#
- # add_timestamps(:suppliers)
+ # add_timestamps(:suppliers, null: false)
#
def add_timestamps(table_name, options = {})
+ emit_warning_if_null_unspecified(options)
add_column table_name, :created_at, :datetime, options
add_column table_name, :updated_at, :datetime, options
end