Fixes #21375: Fix VLANGroup VLAN ID range migration failing on upgrades with existing data #401

Closed
opened 2026-04-05 16:29:54 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 2/6/2026

Fixes: #21375

This PR updates the ipam/migrations/0070_vlangroup_vlan_id_ranges.py data migration to avoid calling save() for each existing VLANGroup. Instead, it calculates the VLAN ID ranges and applies the changes via bulk_update().

Using bulk_update() prevents post_save handlers (notably the search cache/indexing hooks) from running during the migration, which can otherwise raise an AttributeError on instances lacking a comments attribute and abort the upgrade. It also limits the update to only the relevant fields and performs better on larger databases with many VLANGroup rows.

Appreciate your time reviewing this!

*Originally created by @pheus on 2/6/2026* ### Fixes: #21375 This PR updates the `ipam/migrations/0070_vlangroup_vlan_id_ranges.py` data migration to avoid calling `save()` for each existing `VLANGroup`. Instead, it calculates the VLAN ID ranges and applies the changes via `bulk_update()`. Using `bulk_update()` prevents `post_save` handlers (notably the search cache/indexing hooks) from running during the migration, which can otherwise raise an `AttributeError` on instances lacking a `comments` attribute and abort the upgrade. It also limits the update to only the relevant fields and performs better on larger databases with many `VLANGroup` rows. Appreciate your time reviewing this!
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#401