Merge branch '15286-fixes'
[arvados.git] / services / api / db / migrate / 20140117231056_normalize_collection_uuid.rb
index bec7ec7c4aa1066a740275703e12e3c63b0450d5..b9e933e2bff83f20f5386071d52a0d9bfa698ec8 100644 (file)
@@ -1,4 +1,8 @@
-class NormalizeCollectionUuid < ActiveRecord::Migration
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class NormalizeCollectionUuid < ActiveRecord::Migration[4.2]
   def count_orphans
     %w(head tail).each do |ht|
       results = ActiveRecord::Base.connection.execute(<<-EOS)
@@ -25,7 +29,7 @@ EOS
     update_sql <<-EOS
 UPDATE collections
  SET uuid = regexp_replace(uuid,'\\+.*','') || '+' || length(manifest_text)
- WHERE uuid !~ '^[0-9a-f]{32,}\\+[0-9]+'
+ WHERE uuid !~ '^[0-9a-f]{32,}\\+[0-9]+$'
    AND (regexp_replace(uuid,'\\+.*','') || '+' || length(manifest_text))
      NOT IN (SELECT uuid FROM collections)
 EOS
@@ -60,7 +64,7 @@ UPDATE links
    AND (#{ht}_kind='arvados#collection' or #{ht}_uuid ~ '^[0-9a-f]{32,}')
    AND #{ht}_uuid NOT IN (SELECT uuid FROM collections)
    AND regexp_replace(#{ht}_uuid,'\\+.*','') = regexp_replace(c.uuid,'\\+.*','')
-   AND c.uuid ~ '^[0-9a-f]{32,}\\+[0-9]+'
+   AND c.uuid ~ '^[0-9a-f]{32,}\\+[0-9]+$'
 EOS
     end