Closes #21016: Add missing MPTT tree indexes (#21432)

Upgrade django-mptt to 0.18.0 and add empty indexes tuple to MPTT model
Meta classes. The empty tuple triggers Django's migration detection for
indexes that django-mptt adds dynamically (see
django-mptt/django-mptt#682). We cannot define the indexes explicitly
because the MPTT fields don't exist when the Meta class is evaluated.

Affected models: Region, SiteGroup, Location, DeviceRole, Platform,
ModuleBay, InventoryItem, InventoryItemTemplate, TenantGroup,
ContactGroup, WirelessLANGroup
This commit is contained in:
Jason Novinger
2026-02-13 10:00:04 -06:00
committed by GitHub
parent 1190adde2b
commit 0b7375136d
11 changed files with 123 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.2.10 on 2026-02-13 13:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('extras', '0134_owner'),
('users', '0015_owner'),
('wireless', '0017_gfk_indexes'),
]
operations = [
migrations.AddIndex(
model_name='wirelesslangroup',
index=models.Index(fields=['tree_id', 'lft'], name='wireless_wirelesslangroup_fbcd'),
),
]

View File

@@ -63,6 +63,9 @@ class WirelessLANGroup(NestedGroupModel):
class Meta:
ordering = ('name', 'pk')
# Empty tuple triggers Django migration detection for MPTT indexes
# (see #21016, django-mptt/django-mptt#682)
indexes = ()
constraints = (
models.UniqueConstraint(
fields=('parent', 'name'),