Sha256: 6f19f4a50b92dc57bb3b5bc6f09363d11f68bad9a103476d6156b8a8f51c2f50

Contents?: true

Size: 857 Bytes

Versions: 2

Compression:

Stored size: 857 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

2 entries across 2 versions & 1 rubygems

Version Path
card-1.16.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.16.5 db/migrate_core_cards/20150824135418_update_file_history.rb