Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an index to the timestamp column #364

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### 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))
- Context manager set_actor() for use in Celery tasks ([#262](https://github.com/jazzband/django-auditlog/pull/262))

Expand Down
20 changes: 20 additions & 0 deletions auditlog/migrations/0010_alter_logentry_timestamp.py
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
4 changes: 3 additions & 1 deletion auditlog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ class Action:
remote_addr = models.GenericIPAddressField(
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(
blank=True, null=True, verbose_name=_("additional data")
)
Expand Down