Skip to content

Handle WorkerRun foreign keys when deleting a corpus

Erwan Rouchet requested to merge fix-corpus-delete-workerrun into master

Closes #1419 (closed)

I could reproduce locally and tested the fix locally, but could not get the tests to catch fire properly. It took me a while to figure out PostgreSQL was not verifying any foreign key constraint during the tests since they are inside transactions and Django sets all constraints to be DEFERRABLE INITIALLY DEFERRED, and the real life corpus_delete does not run inside of a transaction. I added a new context manager to enforce the foreign keys whenever I want because Postgres isn't my mom.

The tests did catch fire here: https://gitlab.com/teklia/arkindex/backend/-/pipelines/753059975/test_report

Edited by Erwan Rouchet

Merge request reports

Loading