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:
sankalp committed 2026-06-28 16:00:12 +05:45
1 parent 51ad3809dd
commit 86df5d7286
2 files changed
+31

No files matched your search

@@ -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"
),
),
]
+4
View File
@@ -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"],