netbox-documents icon indicating copy to clipboard operation
netbox-documents copied to clipboard

Migration fails with Netbox 4.6.5 & netbox-documents 0.8.5

Open katrinm86 opened this issue 4 months ago • 1 comments

I'm upgrading netbox to the latest version and thus upgraded netbox-documents to 0.8.5 and the last migration fails at the moment

  File "/opt/netbox-4.6.5/venv/lib64/python3.13/site-packages/netbox_documents/migrations/0012_cleanup_stale_contenttypes.py", line 96, in cleanup_stale_content_types
    old_cts.delete()
    ~~~~~~~~~~~~~~^^
  File "/opt/netbox-4.6.5/venv/lib64/python3.13/site-packages/django/db/models/query.py", line 1237, in delete
    collector.collect(del_query)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/opt/netbox-4.6.5/venv/lib64/python3.13/site-packages/django/db/models/deletion.py", line 354, in collect
    raise ProtectedError(
    ...<7 lines>...
    )
django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'ContentType' because they are referenced through protected foreign keys: 'CustomField.related_object_type'.", {<CustomField: CustomField object (28)>, <CustomField: CustomField object (23)>})

Does anybody have any hints on how to solve this?

I commented out the plugin for now to get it running again ...

katrinm86 avatar Jul 21 '26 15:07 katrinm86

OK, i found it on my own:

  • comment out the plugin
  • continue update
  • re-enable plugin
  • find the custom fields for documents that were defined
  • remove them

katrinm86 avatar Jul 21 '26 16:07 katrinm86