Просмотр исходного кода

Add index for (source, path) to DataFile

jeremystretch 3 лет назад
Родитель
Сommit
368e774ceb
2 измененных файлов с 7 добавлено и 0 удалено
  1. 4 0
      netbox/core/migrations/0001_initial.py
  2. 3 0
      netbox/core/models/data.py

+ 4 - 0
netbox/core/migrations/0001_initial.py

@@ -59,4 +59,8 @@ class Migration(migrations.Migration):
             model_name='datafile',
             model_name='datafile',
             constraint=models.UniqueConstraint(fields=('source', 'path'), name='core_datafile_unique_source_path'),
             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'),
+        ),
     ]
     ]

+ 3 - 0
netbox/core/models/data.py

@@ -273,6 +273,9 @@ class DataFile(models.Model):
                 name='%(app_label)s_%(class)s_unique_source_path'
                 name='%(app_label)s_%(class)s_unique_source_path'
             ),
             ),
         )
         )
+        indexes = [
+            models.Index(fields=('source', 'path'), name='core_datafile_source_path'),
+        ]
 
 
     def __str__(self):
     def __str__(self):
         return self.path
         return self.path