Deleting a manuscript doesn't delete its children?
This is observed from the code, rather than tested, but I believe that when a manuscript is deleted, if there are more than two versions of that manuscript then some versions will not be deleted but will be left orphaned in the database.
Currently, I think manuscripts can only be deleted from the Manuscripts page, either via the "Delete" link on the right or the bulk delete button available in NCRC and Colab workflows. Deleting via the link on the right will call deleteManuscript
; bulk delete will call deleteManuscripts
; in each case, the IDs being passed to those mutations are the IDs of latest version manuscripts.
deleteManuscripts
only deletes the specified manuscript objects, so only the latest version of each checked manuscript will be deleted. This isn't currently causing problems because NCRC and Colab don't use versioning.
deleteManuscript
, on the other hand, deletes both the version with the specified ID and the parent if there is one. But it doesn't attempt to delete other versions. So if a manuscript has 5 versions, and you hit "Delete", it will delete the last and the first version and leave versions 2, 3 and 4 orphaned in the database. What's more, each of these will have a parent_id
pointing to a nonexistent parent.
I think the safest may be to add a cascade-delete rule to the DB so that if the parent is deleted, all children must also be deleted; and make both deleteManuscript
and deleteManuscripts
find and delete the parent, so that children are deleted by cascade.