aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-01-25 00:28:31 +1030
committerMatthew Draper <matthew@trebex.net>2016-01-25 00:28:31 +1030
commit235c75972e5985e7b95e3326b8c7c1b9a15ac70c (patch)
tree2064b103741c9f27747e0c3c35872f41f8c8fabd /activerecord/lib
parentdcdadd5e82eed2e64d21399599b14501c3e16cc3 (diff)
parent909818b93b8f1bd4d7053a1c5d8135b9b0cbe865 (diff)
downloadrails-235c75972e5985e7b95e3326b8c7c1b9a15ac70c.tar.gz
rails-235c75972e5985e7b95e3326b8c7c1b9a15ac70c.tar.bz2
rails-235c75972e5985e7b95e3326b8c7c1b9a15ac70c.zip
Merge pull request #23179 from prathamesh-sonpatki/pare-back-default-index-option-to-references
Pare back default `index` option for the migration generator
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb2
-rw-r--r--activerecord/lib/active_record/migration/compatibility.rb12
2 files changed, 13 insertions, 1 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 1cda23dc1d..690e0ba957 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -69,7 +69,7 @@ module ActiveRecord
def initialize(
name,
polymorphic: false,
- index: false,
+ index: true,
foreign_key: false,
type: :integer,
**options
diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb
index 1b94573870..5d742b523b 100644
--- a/activerecord/lib/active_record/migration/compatibility.rb
+++ b/activerecord/lib/active_record/migration/compatibility.rb
@@ -5,6 +5,12 @@ module ActiveRecord
module FourTwoShared
module TableDefinition
+ def references(*, **options)
+ options[:index] ||= false
+ super
+ end
+ alias :belongs_to :references
+
def timestamps(*, **options)
options[:null] = true if options[:null].nil?
super
@@ -24,6 +30,12 @@ module ActiveRecord
end
end
+ def add_reference(*, **options)
+ options[:index] ||= false
+ super
+ end
+ alias :add_belongs_to :add_reference
+
def add_timestamps(*, **options)
options[:null] = true if options[:null].nil?
super