Sha256: af326fa38ea24370f467cab47d25cd43a9e8631a69c0ba72e0857165a1dc34c1

Contents?: true

Size: 849 Bytes

Versions: 14

Compression:

Stored size: 849 Bytes

Contents

# -*- encoding : utf-8 -*-

class UpdateFileHistory < Card::CoreMigration
  def up
    Card.search(type: [:in, 'file', 'image']).each do |card|
      card.actions.each do |action|
        if (content_change = action.change_for(:db_content).first)
          original_filename, file_type, action_id, mod  = content_change.value.split("\n")
          if file_type.present? && action_id.present?
            value =
              if mod.present?
                ":#{card.codename}/#{mod}#{::File.extname(original_filename)}"
              else
                "~#{card.id}/#{action_id}#{::File.extname(original_filename)}"
              end
            content_change.update_attributes! value: value
          end
        end
      end
    end
    Card.search( right: { codename: 'machine_output' } ).each do |card|
      card.delete!
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-1.17.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.17.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.17.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.17.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.17.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.15 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.14 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.13 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.12 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.11 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.10 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.9 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.8 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.7 db/migrate_core_cards/20150824135418_update_file_history.rb