diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2014-12-27 22:35:20 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2014-12-27 23:13:19 +0900 |
commit | 11054049cac40c9d04d940eece155bfb5a7ba1f4 (patch) | |
tree | 90bb5161074846797565deee13ca18e944743f48 | |
parent | de0cfd27a54545131d3ae756eb725a91ab4f0907 (diff) | |
download | rails-11054049cac40c9d04d940eece155bfb5a7ba1f4.tar.gz rails-11054049cac40c9d04d940eece155bfb5a7ba1f4.tar.bz2 rails-11054049cac40c9d04d940eece155bfb5a7ba1f4.zip |
Refactor `PostgreSQL::TableDefinition#primary_key`
Because call the `column` method and set the `options[:primary_key]` is
handled at `super`, here need only treat the `options[:default]`.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb | 6 |
1 files changed, 2 insertions, 4 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 b37630a04c..a9522e152f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb @@ -125,10 +125,8 @@ 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 = {}) - return super unless type == :uuid - options[:default] = options.fetch(:default, 'uuid_generate_v4()') - options[:primary_key] = true - column name, type, options + options[:default] = options.fetch(:default, 'uuid_generate_v4()') if type == :uuid + super end def new_column_definition(name, type, options) # :nodoc: |