1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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]`.
This commit is contained in:
Ryuta Kamizono 2014-12-27 22:35:20 +09:00
parent de0cfd27a5
commit 11054049ca

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: