class AddContentIdToPublisherDocuments < Mongoid::Migration
  def self.up
    Artefact.where(owning_app: 'publisher', content_id: nil).each do |artefact|
      artefact.set(:content_id, SecureRandom.uuid)
    end
  end

  def self.down
  end
end

Set content_id for all publisher's artefacts
Set content_id for all publisher's artefacts

Artefacts belonging to the publisher application are created in
panopticon. We are adding `content_ids` to each artefact on creation.
This migration adds them wherever they're missing.

Uses the atomic `Artefact#set` to prevent callbacks, validations and
observers from firing.
