From 5a911aa5a1c24563e8b12a645b14b9a93c097150 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 28 Aug 2019 10:48:19 -0400 Subject: [PATCH] Fixes #3392: Add database index for ObjectChange time --- CHANGELOG.md | 1 + .../migrations/0025_objectchange_time_index.py | 18 ++++++++++++++++++ netbox/extras/models.py | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 netbox/extras/migrations/0025_objectchange_time_index.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 954fa3de3..df8c933a9 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/netbox/extras/migrations/0025_objectchange_time_index.py b/netbox/extras/migrations/0025_objectchange_time_index.py new file mode 100644 index 000000000..64e74658e --- /dev/null +++ b/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), + ), + ] diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 13b16371d..d764e3d31 100644 --- a/netbox/extras/models.py +++ b/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,