Deleting a Moab from PresCat - sul-dlss/preservation_catalog GitHub Wiki

note 2022-12-16: Andrew is working on a "real procedure"; there is also a similar doc on Consul.

This Is Meant To Be Hard

There isn't an easy way to do this, by design. Deletions are rare.

Identify any existing archive zips

mg599hw5271 version 4 parts 1
  mg/599/hw/5271/mg599hw5271.v0004.zip CURRENT
mg599hw5271 version 3 parts 1
  mg/599/hw/5271/mg599hw5271.v0003.zip CURRENT
mg599hw5271 version 2 parts 8
  mg/599/hw/5271/mg599hw5271.v0002.zip CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z07 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z06 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z05 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z04 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z03 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z02 CURRENT
  mg/599/hw/5271/mg599hw5271.v0002.z01 CURRENT
mg599hw5271 version 1 parts 1
  mg/599/hw/5271/mg599hw5271.v0001.zip CURRENT

...and delete them from archive endpoints using other tools. (cli, gui, whatever works). Be vary careful and document what you deleted.

Delete any tcr or local md records, if necessary

This is left as an exercise for the reader.

Delete records from PresCat

# NOTE, tested a bit indirectly: @jmartin-sul wrote this snippet, and @andrewjbtw used it and said it worked
#
# zip parts destroyed first because they have FK pointing back to parent ZMV.
# then ZMVs can be done.  similary, complete moabs first because they have FK
# back to parent preserved object.  then finally, preserved object.
po = PreservedObject.find_by!(druid: 'mg599hw5271')
po.zipped_moab_versions.find_each do |zmv|
  zmv.zip_parts.destroy_all
end
po.zipped_moab_versions.destroy_all
po.complete_moabs.destroy_all
po.destroy
po.save! # maybe unnecessary?  might even throw an error? :shrug:

If necessary, re-ingest new v1

Sometimes we delete content by re-accessioning the object at version 1 with a stub druid. If this is the case here, re-catalog the druid.