diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-25 08:27:41 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-25 08:30:39 +0900 |
commit | 8f037a5ab929f929fe0897edc9ecadf901c32e56 (patch) | |
tree | 03c8e46e071cee75528bea727c5046e7581c7500 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | 018b16f988dfd129f5dc7091eadda8eb05cdba76 (diff) | |
download | rails-8f037a5ab929f929fe0897edc9ecadf901c32e56.tar.gz rails-8f037a5ab929f929fe0897edc9ecadf901c32e56.tar.bz2 rails-8f037a5ab929f929fe0897edc9ecadf901c32e56.zip |
Extract `integer_like_primary_key_type` to ease to handle it for adapters
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 7 |
1 files changed, 7 insertions, 0 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 1041db0b8f..be2f625d74 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -396,6 +396,9 @@ module ActiveRecord alias :belongs_to :references def new_column_definition(name, type, **options) # :nodoc: + if integer_like_primary_key?(type, options) + type = integer_like_primary_key_type(type, options) + end type = aliased_types(type.to_s, type) options[:primary_key] ||= type == :primary_key options[:null] = false if options[:primary_key] @@ -414,6 +417,10 @@ module ActiveRecord def integer_like_primary_key?(type, options) options[:primary_key] && [:integer, :bigint].include?(type) && !options.key?(:default) end + + def integer_like_primary_key_type(type, options) + type + end end class AlterTable # :nodoc: |