Kaynağa Gözat

Fixes #3392: Add database index for ObjectChange time

Jeremy Stretch 6 yıl önce
ebeveyn
işleme
5a911aa5a1

+ 1 - 0
CHANGELOG.md

@@ -2,6 +2,7 @@ v2.6.3 (FUTURE)
 
 ## Bug Fixes
 
+* [#3392](https://github.com/netbox-community/netbox/issues/3392) - Add database index for ObjectChange time
 * [#3420](https://github.com/netbox-community/netbox/issues/3420) - Serial number filter for racks, devices, and inventory items is now case-insensitive
 * [#3428](https://github.com/netbox-community/netbox/issues/3428) - Fixed cache invalidation issues ([#3300](https://github.com/netbox-community/netbox/issues/3300), [#3363](https://github.com/netbox-community/netbox/issues/3363), [#3379](https://github.com/netbox-community/netbox/issues/3379), [#3382](https://github.com/netbox-community/netbox/issues/3382)) by switching to `prefetch_related()` instead of `select_related()` and removing use of `update()`
 * [#3421](https://github.com/netbox-community/netbox/issues/3421) - Fix exception when ordering power connections list by PDU

+ 18 - 0
netbox/extras/migrations/0025_objectchange_time_index.py

@@ -0,0 +1,18 @@
+# Generated by Django 2.2 on 2019-08-28 14:45
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('extras', '0024_scripts'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='objectchange',
+            name='time',
+            field=models.DateTimeField(auto_now_add=True, db_index=True),
+        ),
+    ]

+ 2 - 1
netbox/extras/models.py

@@ -882,7 +882,8 @@ class ObjectChange(models.Model):
     """
     time = models.DateTimeField(
         auto_now_add=True,
-        editable=False
+        editable=False,
+        db_index=True
     )
     user = models.ForeignKey(
         to=User,