diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-06 05:38:14 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-06 05:38:14 +0900 |
commit | 974e860172b5e0f05a649211c11c328bc9e94a0c (patch) | |
tree | 5cbc7062089354f14ac3329a7a778fd3e1176944 /activerecord/lib/active_record | |
parent | 575212a1ba2e4d170985531402c6e3d27af5a0ea (diff) | |
download | rails-974e860172b5e0f05a649211c11c328bc9e94a0c.tar.gz rails-974e860172b5e0f05a649211c11c328bc9e94a0c.tar.bz2 rails-974e860172b5e0f05a649211c11c328bc9e94a0c.zip |
Make `:auto_increment` option works on `:bigint`
Follow up to #27272.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb index 617b5c35bd..4afb4733eb 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb @@ -44,8 +44,12 @@ module ActiveRecord def primary_key(name, type = :primary_key, **options) if type == :uuid options[:default] = options.fetch(:default, "gen_random_uuid()") - elsif options.delete(:auto_increment) == true && type == :integer - type = :serial + elsif options.delete(:auto_increment) == true && %i(integer bigint).include?(type) + type = if type == :bigint || options[:limit] == 8 + :bigserial + else + :serial + end end super diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb index 5d1e8811f8..d0b38dff4c 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb @@ -3,7 +3,7 @@ module ActiveRecord module SQLite3 module ColumnMethods def primary_key(name, type = :primary_key, **options) - if options.delete(:auto_increment) == true && type == :integer + if options.delete(:auto_increment) == true && %i(integer bigint).include?(type) type = :primary_key end |