1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Update model ordering parameters to ensure deterministic ordering

This commit is contained in:
Jeremy Stretch
2020-01-15 13:20:44 -05:00
parent c202c1325b
commit 28350d84f9
8 changed files with 125 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
# Generated by Django 2.2.8 on 2020-01-15 18:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('dcim', '0088_powerfeed_available_power'),
]
operations = [
migrations.AlterModelOptions(
name='device',
options={'ordering': ('name', 'pk'), 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))},
),
migrations.AlterModelOptions(
name='rack',
options={'ordering': ('site', 'group', 'name', 'pk')},
),
]

View File

@@ -594,8 +594,9 @@ class Rack(ChangeLoggedModel, CustomFieldModel, RackElevationHelperMixin):
}
class Meta:
ordering = ['site', 'group', 'name']
ordering = ('site', 'group', 'name', 'pk') # (site, group, name) may be non-unique
unique_together = [
# Name and facility_id must be unique *only* within a RackGroup
['group', 'name'],
['group', 'facility_id'],
]
@@ -1392,7 +1393,7 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
}
class Meta:
ordering = ['name']
ordering = ('name', 'pk') # Name may be NULL
unique_together = [
['site', 'tenant', 'name'], # See validate_unique below
['rack', 'position', 'face'],