mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00

Recipes come and go over time, so when a recipe gets deleted the history for it goes away, which means that if you look back in time you do not see an accurate picture - you only see the subset of recipes that are currently present. Introduce an indirection between recipes and history that allows for old recipes to persist (mostly in name only). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.11.16 on 2019-02-25 22:51
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
|
|
def populate_recipesymbol(apps, schema_editor):
|
|
RecipeSymbol = apps.get_model('rrs', 'RecipeSymbol')
|
|
RecipeMaintainer = apps.get_model('rrs', 'RecipeMaintainer')
|
|
RecipeUpgrade = apps.get_model('rrs', 'RecipeUpgrade')
|
|
RecipeUpstream = apps.get_model('rrs', 'RecipeUpstream')
|
|
|
|
def populate_model(modelclass):
|
|
for obj in modelclass.objects.all():
|
|
recipe = obj.recipe
|
|
rsym, created = RecipeSymbol.objects.get_or_create(layerbranch=recipe.layerbranch, pn=recipe.pn)
|
|
if created:
|
|
rsym.summary = recipe.summary
|
|
rsym.save()
|
|
obj.recipesymbol = rsym
|
|
obj.save()
|
|
|
|
populate_model(RecipeMaintainer)
|
|
populate_model(RecipeUpgrade)
|
|
populate_model(RecipeUpstream)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('layerindex', '0027_patch_apply_order'),
|
|
('rrs', '0019_maintplan_admin_delete_null'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='RecipeSymbol',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('pn', models.CharField(blank=True, max_length=100)),
|
|
('summary', models.CharField(blank=True, max_length=200)),
|
|
('layerbranch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='layerindex.LayerBranch')),
|
|
],
|
|
),
|
|
migrations.AddField(
|
|
model_name='recipemaintainer',
|
|
name='recipesymbol',
|
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='rrs.RecipeSymbol'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='recipeupgrade',
|
|
name='recipesymbol',
|
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='rrs.RecipeSymbol'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='recipeupstream',
|
|
name='recipesymbol',
|
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='rrs.RecipeSymbol'),
|
|
),
|
|
migrations.RunPython(populate_recipesymbol, reverse_code=migrations.RunPython.noop),
|
|
]
|