Skip to content

Prevent deletion of processes when worker runs are in use

Sentry Issue: ARKINDEX-BACKEND-1KG

IntegrityError: update or delete on table "process_workerrun" violates foreign key constraint "documents_element_...

ForeignKeyViolation: update or delete on table "process_workerrun" violates foreign key constraint "documents_element_worker_run_id_794288c7_fk_process_w" on table "documents_element"
DETAIL:  Key (id)=(88a31896-55bc-4ffb-8e71-de6a481cf08a) is still referenced from table "documents_element".

  File "django/db/backends/base/base.py", line 306, in _commit
    return self.connection.commit()

IntegrityError: update or delete on table "process_workerrun" violates foreign key constraint "documents_element_worker_run_id_794288c7_fk_process_w" on table "documents_element"
DETAIL:  Key (id)=(88a31896-55bc-4ffb-8e71-de6a481cf08a) is still referenced from table "documents_element".

(14 additional frame(s) were not displayed)
...
  File "arkindex/process/api.py", line 404, in destroy

A 400 with explicit message should be raised when worker runs are used on elements or other ml results

See https://redmine.teklia.com/issues/4981

Edited by Bastien Abadie