From 42f62a8e27a5f57b9da9d7e18c87ebade76e8ed7 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Wed, 5 Feb 2020 11:05:43 +0100 Subject: [PATCH] DOI task to delete dois by prefix --- lib/tasks/doi.rake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index ea69240ff..e8c8ef2af 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -99,4 +99,17 @@ namespace :doi do task :migrate_landing_page => :environment do Doi.migrate_landing_page end + + desc 'Delete dois by a prefix' + task :delete_by_prefix => :environment do + if ENV['PREFIX'].nil? + puts "ENV['PREFIX'] is required." + exit + end + + puts "Note: This does not delete any associated prefix." + + count = Doi.delete_dois_by_prefix(ENV['PREFIX']) + puts "#{count} DOIs with prefix #{ENV['PREFIX']} deleted." + end end