13561: Add missing copyright notices on migrations
[arvados.git] / services / api / db / migrate / 20150303210106_fix_collection_portable_data_hash_with_hinted_manifest.rb
index 9bbe113562d7659800023745e3f62b241c53c383..31fc683e20085966c122f46e046dd3bd70722f3c 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'has_uuid'
 require 'kind_and_etag'
 
@@ -55,9 +59,12 @@ class FixCollectionPortableDataHashWithHintedManifest < ActiveRecord::Migration
   end
 
   def each_bad_collection
+    end_coll = Collection.order("id DESC").first
+    return if end_coll.nil?
     seen_uuids = []
     ("A".."Z").each do |hint_char|
-      query = Collection.where("manifest_text LIKE '%+#{hint_char}%'")
+      query = Collection.
+        where("id <= ? AND manifest_text LIKE '%+#{hint_char}%'", end_coll.id)
       unless seen_uuids.empty?
         query = query.where("uuid NOT IN (?)", seen_uuids)
       end