aboutsummaryrefslogtreecommitdiffstats
path: root/rrs/migrations/0013_reup_layerbranch_populate.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-11 11:01:33 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit7606664eeb7a653db9c01c7dbd2bfc11e480f349 (patch)
tree191041b7d14b59b8a2aa45f5ca0a6f3659bf3eca /rrs/migrations/0013_reup_layerbranch_populate.py
parentda3bfff3a1d42d0db144565eaad3710df833d0b5 (diff)
downloadopenembedded-core-contrib-7606664eeb7a653db9c01c7dbd2bfc11e480f349.tar.gz
rrs: link maintenance/upstream history to layerbranch
RecipeUpstreamHistory was not linked to the layer it was produced from, which meant that it wasn't easy to query for a different maintenance plan (i.e. a different layer) and thus the maintenance plan selection on the recipe list didn't really work. Add a link field, populate it in a migration and then make it required. We had added a link earlier from RecipeMaintainerHistory to LayerBranch but it was optional; for the same reasons we now populate it and make it required. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'rrs/migrations/0013_reup_layerbranch_populate.py')
-rw-r--r--rrs/migrations/0013_reup_layerbranch_populate.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/rrs/migrations/0013_reup_layerbranch_populate.py b/rrs/migrations/0013_reup_layerbranch_populate.py
new file mode 100644
index 0000000000..f5e88a76c4
--- /dev/null
+++ b/rrs/migrations/0013_reup_layerbranch_populate.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import settings
+
+
+def populate_layerbranch(apps, schema_editor):
+ RecipeUpstreamHistory = apps.get_model('rrs', 'RecipeUpstreamHistory')
+ LayerBranch = apps.get_model('layerindex', 'LayerBranch')
+ if not settings.CORE_LAYER_NAME:
+ raise Exception('Please set CORE_LAYER_NAME in settings.py')
+ core_layerbranch = LayerBranch.objects.filter(layer__name=settings.CORE_LAYER_NAME).first()
+ if not core_layerbranch:
+ raise Exception('Unable to find core layer "%s" specified in CORE_LAYER_NAME in settings.py' % settings.CORE_LAYER_NAME)
+ for row in RecipeUpstreamHistory.objects.all():
+ row.layerbranch = core_layerbranch
+ row.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0012_reup_layerbranch_field'),
+ ]
+
+ operations = [
+ migrations.RunPython(populate_layerbranch, reverse_code=migrations.RunPython.noop),
+ ]