diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-12-05 14:23:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-05 14:23:04 -0500 |
commit | 575212a1ba2e4d170985531402c6e3d27af5a0ea (patch) | |
tree | d1fc129e79b9d4bb16e5fcf7ded9a0bd643e1d09 /activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb | |
parent | fd87169eb11fc4cfd9082dabe0a85f3bfa385c29 (diff) | |
parent | 000bd6229d92aec2cd46f6bac3d6a7fafb83c5b4 (diff) | |
download | rails-575212a1ba2e4d170985531402c6e3d27af5a0ea.tar.gz rails-575212a1ba2e4d170985531402c6e3d27af5a0ea.tar.bz2 rails-575212a1ba2e4d170985531402c6e3d27af5a0ea.zip |
Merge pull request #27272 from kamipo/make_auto_increment_to_internal_primary_key_option
Make `:auto_increment` to internal primary key option
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb | 7 |
1 files changed, 6 insertions, 1 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 ae1ec3e2b7..617b5c35bd 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb @@ -42,7 +42,12 @@ module ActiveRecord # a record (as primary keys cannot be +nil+). This might be done via the # +SecureRandom.uuid+ method and a +before_save+ callback, for instance. def primary_key(name, type = :primary_key, **options) - options[:default] = options.fetch(:default, "gen_random_uuid()") if type == :uuid + if type == :uuid + options[:default] = options.fetch(:default, "gen_random_uuid()") + elsif options.delete(:auto_increment) == true && type == :integer + type = :serial + end + super end |