Module: ActiveUUID::Patches::Migrations

Defined in:
lib/activeuuid/patches.rb

Instance Method Summary collapse

Instance Method Details

#uuid(*column_names) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/activeuuid/patches.rb', line 38

def uuid(*column_names)
  options = column_names.extract_options!
  column_names.each do |name|
    type = ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql' ? 'uuid' : 'binary(16)'
    column(name, "#{type}#{' PRIMARY KEY' if options.delete(:primary_key)}", options)
  end
end