Sha256: 18224044168da5d82bda4e91b6b462df98976366b4c47a52bd9faee949b62620

Contents?: true

Size: 1.61 KB

Versions: 21

Compression:

Stored size: 1.61 KB

Contents

class MigrateOldPluginTitlesToPluginNamesForUsers < ActiveRecord::Migration
  def self.up
    UserPlugin.find(:all, :conditions => {:user_id => nil}).each { |up| up.destroy }
    User.all.each do |user|
      user.plugins.each do |plugin|
        plugin.update_attribute(:name, case plugin.name
        when "Users"
          "refinery_users"
        when "Dashboard"
          "refinery_dashboard"
        when "Images"
          "refinery_images"
        when "Inquiries"
          "refinery_inquiries"
        when "Pages"
          "refinery_pages"
        when "Refinery"
          "refinery_core"
        when "Settings"
          "refinery_settings"
        when "Resources"
          "refinery_files"
        else
          if (refinery_plugin = ::Refinery::Plugins.registered.find_by_title(plugin.name)).present? and
              refinery_plugin.name.present?
           refinery_plugin.name
          else
            plugin.name.gsub(" ", "_").downcase
          end
        end)
      end
    end
  end

  def self.down
    User.all.each do |user|
      user.plugins.each do |plugin|
        plugin.update_attribute(:name, case plugin.name
        when "refinery_users"
          "Users"
        when "refinery_dashboard"
          "Dashboard"
        when "refinery_images"
          "Images"
        when "refinery_inquiries"
          "Inquiries"
        when "refinery_pages"
          "Pages"
        when "refinery_core"
          "Refinery"
        when "refinery_settings"
          "Settings"
        when "refinery_files"
          "Resources"
        else
          plugin.name.titleize
        end)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
refinerycms-0.9.7.15 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.14 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8.5 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8.4 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8.3 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8.2 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8.1 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.8 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.13 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.11 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.10 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.9 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.8 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.7 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.6 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.5 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.4 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.3 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.2 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb
refinerycms-0.9.7.1 db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb