Sha256: 77b3aab95972b66ede2b32cef584e7c07244e4a12e23d859a2e2dc23923fb82f

Contents?: true

Size: 807 Bytes

Versions: 20

Compression:

Stored size: 807 Bytes

Contents

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

class UpdateFileHistory < Cardio::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

20 entries across 20 versions & 1 rubygems

Version Path
card-1.105.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.5 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.2.pre1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.105.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.104.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.104.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.104.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.103.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.103.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.103.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.103.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.103.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.101.7 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.102.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.101.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.101.5 db/migrate_core_cards/20150824135418_update_file_history.rb