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:
commit
fc8d638549
1 changed files with 2 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue