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

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

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: