Sha256: 207213695e86bfc4f196f7dc8edb062915c4dc384f8e7c41219fa225d6d9a866

Contents?: true

Size: 829 Bytes

Versions: 20

Compression:

Stored size: 829 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

20 entries across 20 versions & 1 rubygems

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