Skip to content

Commit

Permalink
Bug 1278711 - Add unique_together index for job_detail (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
camd committed Aug 8, 2016
1 parent 54abbd4 commit 13943f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions treeherder/model/migrations/0036_job_details_unique_together.py
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('model', '0035_job_detail_field_lengths_decrease'),
]

operations = [
migrations.RunSQL(
# Using ALTER IGNORE so that it will automatically delete duplicates
("ALTER IGNORE TABLE `job_detail` ADD CONSTRAINT "
"`job_detail_title_11a9e7f847f5214c_uniq` "
"UNIQUE (`title`, `value`, `job_id`);"),
state_operations=[
migrations.AlterUniqueTogether(
name='jobdetail',
unique_together=set([('title', 'value', 'job')]),
),
],
),
]
1 change: 1 addition & 0 deletions treeherder/model/models.py
Expand Up @@ -613,6 +613,7 @@ class JobDetail(models.Model):

class Meta:
db_table = "job_detail"
unique_together = ("title", "value", "job")

def __str__(self):
return "{0} {1} {2} {3} {4}".format(self.id,
Expand Down

0 comments on commit 13943f6

Please sign in to comment.