Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a rake task to clean the environment
- Loading branch information
Showing
3 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
desc 'Delete all objects from the environment' | ||
task delete_all_objects: :environment do | ||
puts "Are you sure you want to destroy EVERYTHING? Type \"DELETE\" to confirm." | ||
input = $stdin.gets.chomp | ||
exit if input != 'DELETE' | ||
|
||
total = ActiveFedora::Base.all.count | ||
progressbar = ProgressBar.create(title: "Items to delete", total: total) | ||
ActiveFedora::Base.send(:connections).each do |conn| | ||
conn.search(query) do |object| | ||
progressbar.increment | ||
next if object.pid.start_with?('fedora-system:') | ||
Dor::CleanupService.nuke!(object.pid) | ||
end | ||
end | ||
end |