mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Add an index to the timestamp column (#364)
Many queries, including the default ordering, for the LogEntry model rely on the timestamp field. Adding an index will ensure reasonable scalability for large audit logs.
This commit is contained in:
parent
bcd0d43566
commit
1e7d320a93
3 changed files with 24 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#### Improvements
|
#### Improvements
|
||||||
|
|
||||||
|
- feat: Add db_index to the `LogEntry.timestamp` column ([#364](https://github.com/jazzband/django-auditlog/pull/364))
|
||||||
- feat: Add register model from settings ([#368](https://github.com/jazzband/django-auditlog/pull/368))
|
- feat: Add register model from settings ([#368](https://github.com/jazzband/django-auditlog/pull/368))
|
||||||
- Context manager set_actor() for use in Celery tasks ([#262](https://github.com/jazzband/django-auditlog/pull/262))
|
- Context manager set_actor() for use in Celery tasks ([#262](https://github.com/jazzband/django-auditlog/pull/262))
|
||||||
|
|
||||||
|
|
|
||||||
20
auditlog/migrations/0010_alter_logentry_timestamp.py
Normal file
20
auditlog/migrations/0010_alter_logentry_timestamp.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 4.0.3 on 2022-03-11 23:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("auditlog", "0009_alter_logentry_additional_data"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="logentry",
|
||||||
|
name="timestamp",
|
||||||
|
field=models.DateTimeField(
|
||||||
|
auto_now_add=True, db_index=True, verbose_name="timestamp"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -220,7 +220,9 @@ class LogEntry(models.Model):
|
||||||
remote_addr = models.GenericIPAddressField(
|
remote_addr = models.GenericIPAddressField(
|
||||||
blank=True, null=True, verbose_name=_("remote address")
|
blank=True, null=True, verbose_name=_("remote address")
|
||||||
)
|
)
|
||||||
timestamp = models.DateTimeField(auto_now_add=True, verbose_name=_("timestamp"))
|
timestamp = models.DateTimeField(
|
||||||
|
db_index=True, auto_now_add=True, verbose_name=_("timestamp")
|
||||||
|
)
|
||||||
additional_data = models.JSONField(
|
additional_data = models.JSONField(
|
||||||
blank=True, null=True, verbose_name=_("additional data")
|
blank=True, null=True, verbose_name=_("additional data")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue