Sha256: 2299691c808b82d3046d113b309376cc3825b339539b75a0f498704450567107

Contents?: true

Size: 771 Bytes

Versions: 14

Compression:

Stored size: 771 Bytes

Contents

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

class UpdateFileHistory < Card::Migration::Core
  def up
    Card.search(type: [:in, "file", "image"]).each do |card|
      card.actions.each do |action|
        next unless (content_change = action.change :db_content)
        original_filename, file_type, action_id, mod = content_change.value.split("\n")
        next unless 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
    Card.search(right: { codename: "machine_output" }).each(&:delete!)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-1.91 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.21.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.20.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.20.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.20.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.20.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.20.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.5 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.19.0 db/migrate_core_cards/20150824135418_update_file_history.rb