Sha256: 60e6eb5f18f0cf4ae0ad060ea1eece2b8dd992dbe07dcbc171c4f5e4714ef160

Contents?: true

Size: 814 Bytes

Versions: 31

Compression:

Stored size: 814 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_attributes! value: value
      end
    end
    Card.search(right: { codename: "machine_output" }).each(&:delete!)
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
card-1.96.7 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.6 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.5 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.4 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.96.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.95.3 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.95.2 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.95.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.95.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.94.1 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.94.0 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.13 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.12 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.11 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.10 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.9 db/migrate_core_cards/20150824135418_update_file_history.rb
card-1.93.8 db/migrate_core_cards/20150824135418_update_file_history.rb