aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 00:24:40 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 11:58:43 -0300
commita939506f297b667291480f26fa32a373a18ae06a (patch)
tree67f9dbd9df438ae2bf36b772790939425c446a2b /activerecord/lib
parent94c87156fd67047d96a6805f2f7b8db0a59cd37a (diff)
downloadrails-a939506f297b667291480f26fa32a373a18ae06a.tar.gz
rails-a939506f297b667291480f26fa32a373a18ae06a.tar.bz2
rails-a939506f297b667291480f26fa32a373a18ae06a.zip
Change the default `null` value for `timestamps` to `false`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb18
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb1
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb2
4 files changed, 6 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 68d8a2cd6a..7eaa89c9a7 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -56,18 +56,6 @@ module ActiveRecord
end
end
- module TimestampDefaultDeprecation # :nodoc:
- def emit_warning_if_null_unspecified(options)
- return if options.key?(:null)
-
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- `#timestamp` was called without specifying an option for `null`. In Rails 5,
- this behavior will change to `null: false`. You should manually specify
- `null: true` to prevent the behavior of your existing migrations from changing.
- MSG
- end
- end
-
class ReferenceDefinition # :nodoc:
def initialize(
name,
@@ -167,8 +155,6 @@ module ActiveRecord
# The table definitions
# The Columns are stored as a ColumnDefinition in the +columns+ attribute.
class TableDefinition
- include TimestampDefaultDeprecation
-
# An array of ColumnDefinition objects, representing the column changes
# that have been defined.
attr_accessor :indexes
@@ -375,7 +361,9 @@ module ActiveRecord
# t.timestamps null: false
def timestamps(*args)
options = args.extract_options!
- emit_warning_if_null_unspecified(options)
+
+ options[:null] = false if options[:null].nil?
+
column(:created_at, :datetime, options)
column(:updated_at, :datetime, options)
end
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 34d60493ea..0f44c332ae 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -851,14 +851,14 @@ module ActiveRecord
columns
end
- 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, null: false)
#
def add_timestamps(table_name, options = {})
- emit_warning_if_null_unspecified(options)
+ options[:null] = false if options[:null].nil?
+
add_column table_name, :created_at, :datetime, options
add_column table_name, :updated_at, :datetime, options
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index fa24d9b43f..c3a8bf5c74 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -25,7 +25,6 @@ module ActiveRecord
autoload :TableDefinition
autoload :Table
autoload :AlterTable
- autoload :TimestampDefaultDeprecation
end
autoload_at 'active_record/connection_adapters/abstract/connection_pool' do
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
index f7bf6987c4..fd94a2d038 100644
--- a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
+++ b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
@@ -9,7 +9,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration
<% end -%>
<% end -%>
<% if options[:timestamps] %>
- t.timestamps null: false
+ t.timestamps
<% end -%>
end
<% attributes_with_index.each do |attribute| -%>