Sha256: 86d56940dcd961cd044fe5b313350d989dc50cbd875bdd04847707a50602a061
Contents?: true
Size: 977 Bytes
Versions: 4
Compression:
Stored size: 977 Bytes
Contents
# frozen_string_literal: true namespace :hyrax do namespace :collections do desc 'Update CollectionType global id references for Hyrax 3.0.0' task update_collection_type_global_ids: :environment do puts 'Updating collection -> collection type GlobalId references.' count = 0 Hyrax.query_service.find_all_of_model(model: Hyrax::PcdmCollection).each do |collection| type = Hyrax::CollectionType.find_by_gid(collection.collection_type_gid) next if collection.collection_type_gid == type.to_global_id.to_s # Awful hack to allow converted AF collections to force update collection_type_gid Thread.current[:force_collection_type_gid] = true collection.collection_type_gid = type.to_global_id Hyrax.persister.save(resource: collection) && count += 1 ensure Thread.current[:force_collection_type_gid] = false end puts "Updated #{count} collections." end end end
Version data entries
4 entries across 4 versions & 1 rubygems