Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions script/clear_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def main(collection_name)
solr.delete_by_query "collection_name_facet:#{collection_name}"
solr.commit
ActiveRecord::Base.establish_connection(config[:postgres_worker][:activerecord])
collection_id = Collection.where(name: collection_name).first.id
Item.where(collection_id: collection_id).delete_all
if collection = Collection.where(name: collection_name).first
Item.where(collection_id: collection.id).delete_all
#Delete all documents that point to invalid items.
sql = "DELETE FROM documents WHERE item_id NOT IN (SELECT id FROM items);"
ActiveRecord::Base.connection.execute(sql)
end
sesame = SesameClient.new(config[:sesame_worker])
sesame.clear_repository(collection_name)
sesame.close
Expand Down