From 4f4b5c30094059d6ce34b7f7c658c5e815a4d5b9 Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Sun, 28 May 2023 12:08:44 +0200 Subject: [PATCH] use the index luke --- ...lter_shift_deleted_alter_shift_start_at.py | 23 +++++++++++++++++++ shiftregister/app/models.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 shiftregister/app/migrations/0012_alter_shift_deleted_alter_shift_start_at.py diff --git a/shiftregister/app/migrations/0012_alter_shift_deleted_alter_shift_start_at.py b/shiftregister/app/migrations/0012_alter_shift_deleted_alter_shift_start_at.py new file mode 100644 index 0000000..2629355 --- /dev/null +++ b/shiftregister/app/migrations/0012_alter_shift_deleted_alter_shift_start_at.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.4 on 2023-05-28 10:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("app", "0011_room_description"), + ] + + operations = [ + migrations.AlterField( + model_name="shift", + name="deleted", + field=models.BooleanField(db_index=True, default=False), + ), + migrations.AlterField( + model_name="shift", + name="start_at", + field=models.DateTimeField(db_index=True), + ), + ] diff --git a/shiftregister/app/models.py b/shiftregister/app/models.py index 2a5d52c..26460f2 100644 --- a/shiftregister/app/models.py +++ b/shiftregister/app/models.py @@ -26,13 +26,13 @@ class Room(models.Model): class Shift(models.Model): room = models.ForeignKey(Room, on_delete=models.RESTRICT) - start_at = models.DateTimeField() + start_at = models.DateTimeField(db_index=True) duration = models.DurationField() required_helpers = models.IntegerField( default=0, help_text="When this is set to zero, the room value is used instead." ) description = models.TextField(blank=True, default="") - deleted = models.BooleanField(default=False) + deleted = models.BooleanField(default=False, db_index=True) def with_reg_count(): return Shift.objects.annotate(