Sha256: 0a0e623e3a44462214cff1b524fd22b855cb6cddf4858f3c63ff64eb27afa1f2

Contents?: true

Size: 773 Bytes

Versions: 110

Compression:

Stored size: 773 Bytes

Contents

class UpdateCustomFieldNames < ActiveRecord::Migration[4.2]
  def up
    fields = {}

    Spotlight::CustomField.find_each do |f|
      f.update(field: f.send(:field_name))
      fields[f.solr_field] = f
    end

    Spotlight::SolrDocumentSidecar.find_each do |f|
      f.data.select { |k, v| fields.has_key? k }.each do |k, v|
        f.data[fields[k].send(:field_name)] = f.data.delete(k)
      end
    end
  end

  def down
    fields = {}

    Spotlight::CustomField.find_each do |f|
      fields[f.field] = f
      f.update(field: f.send(:solr_field))
    end

    Spotlight::SolrDocumentSidecar.find_each do |f|
      f.data.select { |k, v| fields.has_key? k }.each do |k, v|
        f.data[fields[k].send(:solr_field)] = f.data.delete(k)
      end
    end
  end
end

Version data entries

110 entries across 110 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.7 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.6 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.5 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.4 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.3 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.2 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-3.0.0.alpha.1 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.13.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.12.1 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.12.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.11.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.10.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.9.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.8.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.7.2 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.7.1 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.7.0 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.6.1.1 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.6.1 db/migrate/20151124105543_update_custom_field_names.rb
blacklight-spotlight-2.6.0 db/migrate/20151124105543_update_custom_field_names.rb