mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
17419 fix MPTT issue with migrations for nested module bays (#17553)
* 17419 rebuild module bay tree on upgrade * 17419 rebuild module bay tree on upgrade * 17419 use get_model
This commit is contained in:
parent
cc6f21ded2
commit
0ec632e548
26
netbox/dcim/migrations/0191_module_bay_rebuild.py
Normal file
26
netbox/dcim/migrations/0191_module_bay_rebuild.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from django.db import migrations
|
||||||
|
import mptt
|
||||||
|
import mptt.managers
|
||||||
|
|
||||||
|
|
||||||
|
def rebuild_mptt(apps, schema_editor):
|
||||||
|
manager = mptt.managers.TreeManager()
|
||||||
|
ModuleBay = apps.get_model('dcim', 'ModuleBay')
|
||||||
|
manager.model = ModuleBay
|
||||||
|
mptt.register(ModuleBay)
|
||||||
|
manager.contribute_to_class(ModuleBay, 'objects')
|
||||||
|
manager.rebuild()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('dcim', '0190_nested_modules'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(
|
||||||
|
code=rebuild_mptt,
|
||||||
|
reverse_code=migrations.RunPython.noop
|
||||||
|
),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user