Module: Uuidable::TableDefinition

Defined in:
lib/uuidable/migration.rb

Overview

Module adds method to table definition

Instance Method Summary collapse

Instance Method Details

#uuid(opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/uuidable/migration.rb', line 9

def uuid(opts = {})
  index_opts = opts.delete(:index)
  index_opts = {} if index_opts.nil?

  column_name = opts.delete(:column_name) || COLUMN_NAME

  column column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)
  index column_name, INDEX_OPTIONS.merge(index_opts) if index_opts
end