Sipity entities not cleaned up from DB after deletion
Descriptive summary
After deleting a work in a sipity workflow from a hyrax 3 or 4 instance the work will continue to appear in the sipity_entities table (and probably the other sipity tables as well). The record is cleaned out of solr, and becomes a fcr:tombstone in fedora, but lives on in the relational database forever.
For example, in my .dassie environment I deleted the work with id vt150j246, but if I check the database I still see:
hyrax=# select * from sipity_entities where proxy_for_global_id = 'gid://dassie/GenericWork/vt150j246';
id | proxy_for_global_id | workflow_id | workflow_state_id | created_at | updated_at
----+------------------------------------+-------------+-------------------+----------------------------+----------------------------
9 | gid://dassie/GenericWork/vt150j246 | 4 | 6 | 2023-04-04 17:15:23.501994 | 2023-04-04 17:15:23.568498
Rationale
This is an issue since some pages are directly populated from queries of the database. For example, the Review Submissions page queries for sipity entities, and then looks those ids up in solr to return pages of results. The result is fewer than a full page of results will be returned, since the deleted items are returned from the DB but not found in solr.
Expected behavior
Sipity tables clear out entries related to deleted works.
Actual behavior
Sipity tables are unchanged when a work is deleted
Steps to reproduce the behavior
- Create a work in a workflow (such as the default Mediated workflow)
- connect to the database and query for the work (see query above)
- In the UI, delete the work
- Query the database again, you will see the entry still there
Related work
Relates to https://github.com/samvera/hyrax/pull/5999 since this PR enables serverside paging for the Review Submissions page, which makes it visible when there are leftover deleted items in the sipity_entities table, since you can end up with pages of results that contain significantly fewer results than the page size.