Add index on api_check (status, user, alert_after), will be used in sendalerts management command.

This commit is contained in:
Pēteris Caune 2015-10-22 13:15:57 +03:00
parent 88bd760925
commit a4afd70fef
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0014_auto_20151019_2039'),
]
operations = [
migrations.AlterIndexTogether(
name='check',
index_together=set([('status', 'user', 'alert_after')]),
),
]

View File

@ -25,6 +25,11 @@ CHANNEL_KINDS = (("email", "Email"), ("webhook", "Webhook"),
class Check(models.Model):
class Meta:
# sendalerts command will query using these
index_together = ["status", "user", "alert_after"]
name = models.CharField(max_length=100, blank=True)
code = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True)
user = models.ForeignKey(User, blank=True, null=True)