Class: Nochmal::Adapters::CarrierwaveResume

Inherits:
CarrierwaveMigration show all
Defined in:
lib/nochmal/adapters/carrierwave_resume.rb

Overview

Resume a started migration

Constant Summary

Constants inherited from Carrierwave

Nochmal::Adapters::Carrierwave::PREFIX

Instance Method Summary collapse

Methods inherited from CarrierwaveMigration

#attachment_types_for, #collection, #item_completed, #teardown, #type_completed

Methods inherited from Carrierwave

#blob, #collection, #models_with_attachments

Methods inherited from Base

#attachment_types_for, #blob, #collection, #count, #empty_collection?, #from_storage_service, #general_notes, #initialize, #item_completed, #list, #model_completed, #models_with_attachments, #teardown, #to_storage_service, #type_completed, #type_notes, #validate

Constructor Details

This class inherits a constructor from Nochmal::Adapters::Base

Instance Method Details

#reupload(record, type) ⇒ Object

action



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/nochmal/adapters/carrierwave_resume.rb', line 9

def reupload(record, type)
  status = MigrationData::Status.find_by(
    record_id: record.id, record_type: record.class.sti_name,
    uploader_type: type, filename: blob(record.send(type)).to_s
  )

  if status&.migrated?
    message = status.missing_message if status.missing?
    { status: :skip, message: message }
  else
    super(record, type)
  end
end

#setup(action) ⇒ Object

hooks



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/nochmal/adapters/carrierwave_resume.rb', line 25

def setup(action)
  if MigrationData::Status.table_exists? && MigrationData::Meta.table_exists?
    @mode = action
    return true
  end

  Output.notes [
    "It appears that no previous migration has been running.",
    'Creating the needed tables and "resuming from square 1"...'
  ]
  super
end