mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-19 07:30:01 +02:00
Merge pull request #21842 from netbox-community/21455-sql-indexes-audit
Closes #21455: Add SQL indexes for default ordering
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('dcim', '0231_default_ordering_indexes'),
|
||||
('extras', '0137_default_ordering_indexes'),
|
||||
('ipam', '0089_default_ordering_indexes'),
|
||||
('tenancy', '0024_default_ordering_indexes'),
|
||||
('users', '0016_default_ordering_indexes'),
|
||||
('virtualization', '0054_virtualmachinetype'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='virtualmachine',
|
||||
index=models.Index(fields=['name', 'id'], name='virtualizat_name_16033e_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='virtualmachinetype',
|
||||
index=models.Index(fields=['name'], name='virtualizat_name_6cff11_idx'),
|
||||
),
|
||||
]
|
||||
@@ -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