Sha256: 62cb1f84d5c7b227386a6808bf6e254d3680c2d515d47bb1e9f2f0a97f3cdc37

Contents?: true

Size: 917 Bytes

Versions: 23

Compression:

Stored size: 917 Bytes

Contents

class ChangeSearchAttributeToMethod < ActiveRecord::Migration
  class Search < ActiveRecord::Base
    include Discerner::Methods::Models::Parameter
  end

  def self.up
    add_column :discerner_parameters, :search_method, :string

    Discerner::Parameter.order(:id).each do |p|
      p.search_method = p.search_attribute
      p.save!
    end

    remove_index :discerner_parameters, :name => 'index_discerner_parameters'
    remove_column :discerner_parameters, :search_attribute
  end

  def self.down
    add_column :discerner_parameters, :search_attribute, :string

    Discerner::Parameter.order(:id).each do |p|
      p.search_attribute = p.search_method
      p.save!
    end

    remove_column :discerner_parameters, :search_method
    add_index :discerner_parameters, [:search_model, :search_attribute, :parameter_category_id, :deleted_at], :unique => true, :name => 'index_discerner_parameters'
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
discerner-2.0.16 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.15 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.14 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.13 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-1.2.2 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.12 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-1.2.1 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.11 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.10 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-1.2.0 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.9 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.8 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.7 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.6 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.5 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.4 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.3 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.2 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.1 db/migrate/20130222052924_change_search_attribute_to_method.rb
discerner-2.0.0 db/migrate/20130222052924_change_search_attribute_to_method.rb