Method: Lockbox::Migrator#migrate

Defined in:
lib/lockbox/migrator.rb

#migrate(restart:) ⇒ Object

TODO add attributes option



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lockbox/migrator.rb', line 26

def migrate(restart:)
  fields = model.respond_to?(:lockbox_attributes) ? model.lockbox_attributes.select { |k, v| v[:migrating] } : {}

  # need blind indexes for building relation
  blind_indexes = model.respond_to?(:blind_indexes) ? model.blind_indexes.select { |k, v| v[:migrating] } : {}

  attachments = model.respond_to?(:lockbox_attachments) ? model.lockbox_attachments.select { |k, v| v[:migrating] } : {}

  perform(fields: fields, blind_indexes: blind_indexes, restart: restart) if fields.any? || blind_indexes.any?
  perform_attachments(attachments: attachments, restart: restart) if attachments.any?
end