Module: Uuidable::TableDefinition

Defined in:
lib/uuidable/migration.rb

Overview

Module adds method to table definition

Instance Method Summary collapse

Instance Method Details

#uuid(column_name = COLUMN_NAME, **opts) ⇒ Object



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

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

  column_name ||= opts.delete(:column_name)

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