From 9a19b4bdec0eb1389e4386915bc384bb378c2ce1 Mon Sep 17 00:00:00 2001 From: DiogoPaciencia Date: Mon, 5 Feb 2024 21:41:39 +0000 Subject: [PATCH] changed outdated Django syntax to updated Django syntax --- django_cron/migrations/0001_initial.py | 20 +++++++++++--------- django_cron/models.py | 11 ++++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/django_cron/migrations/0001_initial.py b/django_cron/migrations/0001_initial.py index 5cf8d85..36ed632 100644 --- a/django_cron/migrations/0001_initial.py +++ b/django_cron/migrations/0001_initial.py @@ -34,14 +34,16 @@ class Migration(migrations.Migration): ), ], ), - migrations.AlterIndexTogether( - name='cronjoblog', - index_together=set( - [ - ('code', 'is_success', 'ran_at_time'), - ('code', 'start_time', 'ran_at_time'), - ('code', 'start_time'), - ] - ), + migrations.AddIndex( + model_name='cronjoblog', + index=models.Index(fields=['code', 'is_success', 'ran_at_time'], name='cronjoblog_code_success_ran_at_time_idx'), + ), + migrations.AddIndex( + model_name='cronjoblog', + index=models.Index(fields=['code', 'start_time', 'ran_at_time'], name='cronjoblog_code_start_time_ran_at_time_idx'), + ), + migrations.AddIndex( + model_name='cronjoblog', + index=models.Index(fields=['code', 'start_time'], name='cronjoblog_code_start_time_idx'), ), ] diff --git a/django_cron/models.py b/django_cron/models.py index c109e09..a0e7eeb 100644 --- a/django_cron/models.py +++ b/django_cron/models.py @@ -24,13 +24,10 @@ def __str__(self): return "%s (%s)" % (self.code, "Success" if self.is_success else "Fail") class Meta: - index_together = [ - ('code', 'is_success', 'ran_at_time'), - ('code', 'start_time', 'ran_at_time'), - ( - 'code', - 'start_time', - ), # useful when finding latest run (order by start_time) of cron + indexes = [ + models.Index(fields=['code', 'is_success', 'ran_at_time']), + models.Index(fields=['code', 'start_time', 'ran_at_time']), + models.Index(fields=['code', 'start_time']), ] app_label = 'django_cron'