Sha256: 61649b37375c48dd31a720e8f9ac35d6964bd32afeae5ff9d62d71d25bbb5181

Contents?: true

Size: 803 Bytes

Versions: 15

Compression:

Stored size: 803 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)
        next if content_change.new_record?
        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! value: value
      end
    end
    Card.search(right: { codename: "machine_output" }).each(&:delete!)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
card-1.100.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.5 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.99.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.98.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.98.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.98.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.98.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.97.0.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.97.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.8 db/migrate_core_cards/20150824135418_update_file_history.rb