mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-12 20:19:50 +02:00
Add SQL indexes for default ordering on applicable models
This commit is contained in:
@@ -97,6 +97,9 @@ class Cluster(ContactsMixin, CachedScopeMixin, PrimaryModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
indexes = (
|
||||
models.Index(fields=('name',)), # Default ordering
|
||||
)
|
||||
constraints = (
|
||||
models.UniqueConstraint(
|
||||
fields=('group', 'name'),
|
||||
|
||||
@@ -92,6 +92,9 @@ class VirtualMachineType(ImageAttachmentsMixin, PrimaryModel):
|
||||
violation_error_message=_('Virtual machine type slug must be unique.'),
|
||||
),
|
||||
)
|
||||
indexes = (
|
||||
models.Index(fields=('name',)), # Default ordering
|
||||
)
|
||||
verbose_name = _('virtual machine type')
|
||||
verbose_name_plural = _('virtual machine types')
|
||||
|
||||
@@ -249,6 +252,9 @@ class VirtualMachine(
|
||||
|
||||
class Meta:
|
||||
ordering = ('name', 'pk') # Name may be non-unique
|
||||
indexes = (
|
||||
models.Index(fields=('name', 'id')), # Default ordering
|
||||
)
|
||||
constraints = (
|
||||
models.UniqueConstraint(
|
||||
Lower('name'), 'cluster', 'tenant',
|
||||
|
||||
Reference in New Issue
Block a user