Bulk deletion of expired changelog records does not support cascades #10907

Closed
opened 2025-12-29 21:37:34 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 17, 2025).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

NetBox Cloud

NetBox Version

v4.2.5

Python Version

3.10

Steps to Reproduce

This issue manifests when a plugin-provided model has a relationship to NetBox's ObjectChange model. See netboxlabs/netbox-branching#175 for instance.

Expected Behavior

When running the housekeeping management command, all expired changelog records should be deleted successfully.

Observed Behavior

If there exists a relation from some other model to the ObjectChange model, the deletion of the ObjectChange record may fail due to a constraint violation. For example:

django.db.utils.IntegrityError: update or delete on table "core_objectchange" violates foreign key constraint "netbox_branching_app_change_id_5ac5eb3f_fk_core_obje" on table "netbox_branching_appliedchange"
DETAIL: Key (id)=(8) is still referenced from table "netbox_branching_appliedchange".

Originally created by @jeremystretch on GitHub (Mar 17, 2025). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type NetBox Cloud ### NetBox Version v4.2.5 ### Python Version 3.10 ### Steps to Reproduce This issue manifests when a plugin-provided model has a relationship to NetBox's ObjectChange model. See netboxlabs/netbox-branching#175 for instance. ### Expected Behavior When running the `housekeeping` management command, all expired changelog records should be deleted successfully. ### Observed Behavior If there exists a relation from some other model to the ObjectChange model, the deletion of the ObjectChange record may fail due to a constraint violation. For example: > django.db.utils.IntegrityError: update or delete on table "core_objectchange" violates foreign key constraint "netbox_branching_app_change_id_5ac5eb3f_fk_core_obje" on table "netbox_branching_appliedchange" > DETAIL: Key (id)=(8) is still referenced from table "netbox_branching_appliedchange".
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:37:34 +01:00
adam closed this issue 2025-12-29 21:37:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10907