Sha256: f4f3ddc057fee454b54ae2141eb4049a6f6ca21b01c3e05ecf3fa1085bfd5c41

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

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

class FixModFiles < Cardio::Migration::Core
  def up
    Card.search(type: "image").each do |card|
      next unless card.coded?
      next unless card.db_content.include?("05_standard") ||
                  card.db_content.include?("06_bootstrap")
      new_content = card.db_content.sub("05_standard", "standard")
                        .sub("06_bootstrap", "bootstrap")
      card.update_column :db_content, new_content

      update_history card
    end
  end

  def update_history card
    card.actions.each do |action|
      next unless (content_change = action.change(:db_content))
      new_value = content_change.value.gsub("05_standard", "standard")
                                .gsub("06_bootstrap", "bootstrap")
      content_change.update_column :value, new_value
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.101.4 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.101.3 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.101.2 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.101.1 db/migrate_core_cards/20160914132636_fix_mod_files.rb
card-1.101.0 db/migrate_core_cards/20160914132636_fix_mod_files.rb