提交 11054049 编写于 作者: R Ryuta Kamizono

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]`.
上级 de0cfd27
......@@ -125,10 +125,8 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
# 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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册