class SetDocumentIdOnContentItems < ActiveRecord::Migration[5.0]
  def up
    Document.find_each do |doc|
      ContentItem.where(content_id: doc.content_id, locale: doc.locale)
        .update_all(document_id: doc.id)
    end
  end
end

class SetDocumentIdOnContentItems < ActiveRecord::Migration[5.0]
  disable_ddl_transaction!

  def up
    Document.find_each do |doc|
      ContentItem.where(content_id: doc.content_id, locale: doc.locale)
        .update_all(document_id: doc.id)
    end
  end
end

Set document ids outside of a transaction
Set document ids outside of a transaction

Since these can be safely re-attempted if this migration fails we'll run
this outside of a transaction and lesser the risk of deadlocks.
