summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-18 16:43:05 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit32617fc366b64953426da94b457f16a885b35779 (patch)
treeccded7607136f9a66df18995af1af75d0ffca41f
parent50f7c7036a4872f84a34dc30ce4bcebb6cc7ac66 (diff)
downloadopenembedded-core-contrib-32617fc366b64953426da94b457f16a885b35779.tar.gz
openembedded-core-contrib-32617fc366b64953426da94b457f16a885b35779.tar.bz2
openembedded-core-contrib-32617fc366b64953426da94b457f16a885b35779.zip
rrs: fix unique constraint on RecipeMaintainerHistory sha1 field
Although it's unlikely to be an issue, technically we shouldn't be insisting the sha1 field be unique globally, just within each layerbranch, so adjust the constraints. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--rrs/migrations/0018_rmh_unique.py25
-rw-r--r--rrs/models.py5
2 files changed, 29 insertions, 1 deletions
diff --git a/rrs/migrations/0018_rmh_unique.py b/rrs/migrations/0018_rmh_unique.py
new file mode 100644
index 0000000000..e378357a98
--- /dev/null
+++ b/rrs/migrations/0018_rmh_unique.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.12 on 2018-04-18 05:42
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('layerindex', '0013_patch'),
+ ('rrs', '0017_maintenanceplan_maintainer_style'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='recipemaintainerhistory',
+ name='sha1',
+ field=models.CharField(max_length=64),
+ ),
+ migrations.AlterUniqueTogether(
+ name='recipemaintainerhistory',
+ unique_together=set([('layerbranch', 'sha1')]),
+ ),
+ ]
diff --git a/rrs/models.py b/rrs/models.py
index 2ae3353126..38099f6044 100644
--- a/rrs/models.py
+++ b/rrs/models.py
@@ -225,9 +225,12 @@ class RecipeMaintainerHistory(models.Model):
title = models.CharField(max_length=255, blank=True)
date = models.DateTimeField(db_index=True)
author = models.ForeignKey(Maintainer)
- sha1 = models.CharField(max_length=64, unique=True)
+ sha1 = models.CharField(max_length=64)
layerbranch = models.ForeignKey(LayerBranch)
+ class Meta:
+ unique_together = ('layerbranch', 'sha1',)
+
@staticmethod
def get_last(layerbranch):
rmh_qry = RecipeMaintainerHistory.objects.filter(layerbranch=layerbranch).order_by('-date')