Merge pull request #18221 from kamipo/refactor_table_definition_primary_key

Refactor `PostgreSQL::TableDefinition#primary_key`
This commit is contained in:
Sean Griffin 2014-12-27 07:40:33 -07:00
commit fc8d638549
1 changed files with 2 additions and 4 deletions

View File

@ -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: