mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Add a DB index to LogEntry's action field (#236)
For some applications the possibility to filter by the `action` field might be really interesting. However the lack of an index can lead to severe reduction of such queries. The simplest solution: Let's a DB index on that field :)
This commit is contained in:
parent
620d716513
commit
938431389f
2 changed files with 21 additions and 1 deletions
20
auditlog/migrations/0008_action_index.py
Normal file
20
auditlog/migrations/0008_action_index.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0007_object_pk_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="logentry",
|
||||
name="action",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
choices=[(0, "create"), (1, "update"), (2, "delete")],
|
||||
db_index=True,
|
||||
verbose_name="action",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
@ -213,7 +213,7 @@ class LogEntry(models.Model):
|
|||
)
|
||||
object_repr = models.TextField(verbose_name=_("object representation"))
|
||||
action = models.PositiveSmallIntegerField(
|
||||
choices=Action.choices, verbose_name=_("action")
|
||||
choices=Action.choices, verbose_name=_("action"), db_index=True
|
||||
)
|
||||
changes = models.TextField(blank=True, verbose_name=_("change message"))
|
||||
actor = models.ForeignKey(
|
||||
|
|
|
|||
Loading…
Reference in a new issue