aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2014-12-27 22:35:20 +0900
committerRyuta Kamizono <kamipo@gmail.com>2014-12-27 23:13:19 +0900
commit11054049cac40c9d04d940eece155bfb5a7ba1f4 (patch)
tree90bb5161074846797565deee13ca18e944743f48 /activerecord/lib/active_record
parentde0cfd27a54545131d3ae756eb725a91ab4f0907 (diff)
downloadrails-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]`.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb6
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: