Sha256: ef1ebd2ce1bbfcf598bf20360265b9ee829f04a656632cc8c86f2950e4aaf3cf

Contents?: true

Size: 738 Bytes

Versions: 107

Compression:

Stored size: 738 Bytes

Contents

class AddPolymorphicDocumentToSidecars < ActiveRecord::Migration[4.2]
  def change
    add_column :spotlight_solr_document_sidecars, :document_id, :string
    add_column :spotlight_solr_document_sidecars, :document_type, :string

    reversible do |dir|
      dir.up do
        Spotlight::SolrDocumentSidecar.find_each do |e|
          e.document = SolrDocument.new(id: e.solr_document_id)
          e.save!
        end
      end

      dir.down do
        Spotlight::SolrDocumentSidecar.find_each do |e|
          e.solr_document_id = e.document_id
          e.save!
        end
      end
    end

    remove_column :spotlight_solr_document_sidecars, :solr_document_id

    add_index :bookmarks, [:document_type, :document_id]
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
blacklight-spotlight-1.4.0 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.3.0 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.2.0 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.1.0 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.0.0 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.0.0.alpha2 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb
blacklight-spotlight-1.0.0.alpha1 db/migrate/20150217111511_add_polymorphic_document_to_sidecars.rb