From 368e774ceb9af0e7713f0e2e2558ee99536a12f0 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 17 Feb 2023 08:49:00 -0500 Subject: [PATCH] Add index for (source, path) to DataFile --- netbox/core/migrations/0001_initial.py | 4 ++++ netbox/core/models/data.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/netbox/core/migrations/0001_initial.py b/netbox/core/migrations/0001_initial.py index 37c3b617e..0678d4a67 100644 --- a/netbox/core/migrations/0001_initial.py +++ b/netbox/core/migrations/0001_initial.py @@ -59,4 +59,8 @@ class Migration(migrations.Migration): model_name='datafile', constraint=models.UniqueConstraint(fields=('source', 'path'), name='core_datafile_unique_source_path'), ), + migrations.AddIndex( + model_name='datafile', + index=models.Index(fields=['source', 'path'], name='core_datafile_source_path'), + ), ] diff --git a/netbox/core/models/data.py b/netbox/core/models/data.py index 67ab4a6c7..eaeef5f88 100644 --- a/netbox/core/models/data.py +++ b/netbox/core/models/data.py @@ -273,6 +273,9 @@ class DataFile(models.Model): name='%(app_label)s_%(class)s_unique_source_path' ), ) + indexes = [ + models.Index(fields=('source', 'path'), name='core_datafile_source_path'), + ] def __str__(self): return self.path