diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-23 15:34:56 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-23 15:48:49 +0900 |
commit | 202d6578f44ab03ee89ed57b73a97d513fc5a008 (patch) | |
tree | 40b9dbe22068b0d60c157deb98a98c42b3527619 /activerecord/lib/active_record/connection_adapters/mysql | |
parent | dfe6939e16bdcf854d32b61933d55fe313ac49fb (diff) | |
download | rails-202d6578f44ab03ee89ed57b73a97d513fc5a008.tar.gz rails-202d6578f44ab03ee89ed57b73a97d513fc5a008.tar.bz2 rails-202d6578f44ab03ee89ed57b73a97d513fc5a008.zip |
Move integer-like primary key normalization to `new_column_definition`
Currently the normalization only exists in `primary_key` shorthand. It
should be moved to `new_column_definition` to also affect to
`add_column` with primary key.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb index b22a2e4da7..eff96af87a 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb @@ -4,11 +4,6 @@ module ActiveRecord module ConnectionAdapters module MySQL module ColumnMethods - def primary_key(name, type = :primary_key, **options) - options[:auto_increment] = true if [:integer, :bigint].include?(type) && !options.key?(:default) - super - end - def blob(*args, **options) args.each { |name| column(name, :blob, options) } end @@ -62,6 +57,10 @@ module ActiveRecord include ColumnMethods def new_column_definition(name, type, **options) # :nodoc: + if integer_like_primary_key?(type, options) + options[:auto_increment] = true + end + case type when :virtual type = options[:type] |