From 11054049cac40c9d04d940eece155bfb5a7ba1f4 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 27 Dec 2014 22:35:20 +0900 Subject: 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]`. --- .../connection_adapters/postgresql/schema_definitions.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb') 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: -- cgit v1.2.3