Module: Uuidable::Migration
- Defined in:
- lib/uuidable/migration.rb
Overview
Module adds method to alter table migration
Instance Method Summary collapse
- #add_uuid_column(table_name, column_name = COLUMN_NAME, **opts) ⇒ Object
- #add_uuid_index(table_name, opts = {}) ⇒ Object
Instance Method Details
#add_uuid_column(table_name, column_name = COLUMN_NAME, **opts) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/uuidable/migration.rb', line 24 def add_uuid_column(table_name, column_name = COLUMN_NAME, **opts) index_opts = opts.delete(:index) index_opts = {} if index_opts == true column_name ||= opts.delete(:column_name) add_column table_name, column_name, COLUMN_TYPE, **COLUMN_OPTIONS.merge(opts) add_uuid_index(table_name, index_opts.merge(column_name: column_name)) if index_opts end |
#add_uuid_index(table_name, opts = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/uuidable/migration.rb', line 35 def add_uuid_index(table_name, opts = {}) column_name = opts.delete(:column_name) || COLUMN_NAME add_index table_name, column_name, **INDEX_OPTIONS.merge(opts) end |