From 01bf8ba23d435c25b6a2fccd9ef9df16ec62ac53 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Fri, 25 Oct 2024 08:41:29 +0200 Subject: [PATCH] fix: db indexes --- ...uni_ticket__office__f42ab9_idx_and_more.py | 25 +++++++++++++++++++ uniticket/uni_ticket/models.py | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 uniticket/uni_ticket/migrations/0022_remove_ticketassignment_uni_ticket__office__f42ab9_idx_and_more.py diff --git a/uniticket/uni_ticket/migrations/0022_remove_ticketassignment_uni_ticket__office__f42ab9_idx_and_more.py b/uniticket/uni_ticket/migrations/0022_remove_ticketassignment_uni_ticket__office__f42ab9_idx_and_more.py new file mode 100644 index 00000000..dc561a96 --- /dev/null +++ b/uniticket/uni_ticket/migrations/0022_remove_ticketassignment_uni_ticket__office__f42ab9_idx_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.9 on 2024-10-25 06:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('uni_ticket', '0021_alter_task_options_alter_ticketcategorytask_options_and_more'), + ] + + operations = [ + migrations.RemoveIndex( + model_name='ticketassignment', + name='uni_ticket__office__f42ab9_idx', + ), + migrations.AddIndex( + model_name='ticket', + index=models.Index(fields=['priority', 'created'], name='uni_ticket__priorit_0066dd_idx'), + ), + migrations.AddIndex( + model_name='ticketassignment', + index=models.Index(fields=['office_id', 'follow', 'taken_date'], name='uni_ticket__office__54a01d_idx'), + ), + ] diff --git a/uniticket/uni_ticket/models.py b/uniticket/uni_ticket/models.py index 32558667..b06a56ae 100644 --- a/uniticket/uni_ticket/models.py +++ b/uniticket/uni_ticket/models.py @@ -503,6 +503,7 @@ class Meta: ] verbose_name = _("Ticket") verbose_name_plural = _("Ticket") + indexes = [models.Index(fields=["priority", "created"])] @property def taken_date(self): @@ -1186,7 +1187,7 @@ class TicketAssignment(TimeStampedModel): class Meta: unique_together = ("ticket", "office") ordering = ["created"] - indexes = [models.Index(fields=["office_id", "follow"])] + indexes = [models.Index(fields=["office_id", "follow", "taken_date"])] verbose_name = _("Competenza Ticket") verbose_name_plural = _("Competenza Ticket")