Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions django_cron/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
]
11 changes: 4 additions & 7 deletions django_cron/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down