feat(src/notifications): add indexes for deadline reminder and notification models
Prevent missing indexes that slow queries on ticket/user and user/created_at fields.
This commit is contained in:
2 files changed
+31
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 6.0.6 on 2026-06-28 10:14
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("notifications", "0001_initial"),
|
||||
("tickets", "0002_ticketcomment_ticket_comm_ticket__5ef05d_idx_and_more"),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="deadlinereminderlog",
|
||||
index=models.Index(
|
||||
fields=["ticket", "user"], name="deadline_re_ticket__850437_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="notification",
|
||||
index=models.Index(
|
||||
fields=["user", "created_at"], name="notificatio_user_id_7336fd_idx"
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -24,6 +24,7 @@ class Notification(models.Model):
|
||||
verbose_name_plural = "Notifications"
|
||||
indexes = [
|
||||
models.Index(fields=["user", "read_at"]),
|
||||
models.Index(fields=["user", "created_at"]),
|
||||
]
|
||||
ordering = ("-created_at",)
|
||||
|
||||
@@ -51,6 +52,9 @@ class DeadlineReminderLog(models.Model):
|
||||
db_table = "deadline_reminder_log"
|
||||
verbose_name = "Deadline Reminder Log"
|
||||
verbose_name_plural = "Deadline Reminder Logs"
|
||||
indexes = [
|
||||
models.Index(fields=["ticket", "user"]),
|
||||
]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["ticket", "user", "days_before"],
|
||||
|
||||
Reference in new issue
Block a user