X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/07a7c1ca8ea3fb014a7eb4922ef762af7da5a0b5..a7631a1ccb6e2a6925d00a06562e171c4ce4ea2f:/services/api/db/migrate/20140117231056_normalize_collection_uuid.rb diff --git a/services/api/db/migrate/20140117231056_normalize_collection_uuid.rb b/services/api/db/migrate/20140117231056_normalize_collection_uuid.rb index bec7ec7c4a..b9e933e2bf 100644 --- a/services/api/db/migrate/20140117231056_normalize_collection_uuid.rb +++ b/services/api/db/migrate/20140117231056_normalize_collection_uuid.rb @@ -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