@@ -0,0 +1,2375 @@
+from django.db import migrations%0A%0A%0Adef drop_all_environment_relations(apps, schema_editor):%0A    Variable = apps.get_model('proso_models', 'Variable')%0A    Variable.objects.filter(key__in=%5B'parent', 'child'%5D).delete()%0A%0A%0Adef move_category_structure(apps, schema_editor):%0A    Category = apps.get_model('proso_flashcards', %22Category%22)%0A    ItemRelation = apps.get_model('proso_models', 'ItemRelation')%0A    categories = Category.objects.prefetch_related('subcategories', 'terms', 'contexts').all()%0A    for category in categories:%0A        parent_id = category.item_id%0A        visible = category.not_in_model%0A        for subobject in list(category.subcategories.all()) + list(category.terms.all()) + list(category.contexts.all()):%0A            ItemRelation.objects.get_or_create(%0A                parent_id=parent_id,%0A                child_id=subobject.item_id,%0A                visible=visible%0A            )%0A%0A%0Adef move_term_structure(apps, schema_editor):%0A    Term = apps.get_model('proso_flashcards', %22Term%22)%0A    ItemRelation = apps.get_model('proso_models', 'ItemRelation')%0A    terms = Term.objects.prefetch_related('flashcards').all()%0A    for term in terms:%0A        parent_id = term.item_id%0A        for flashcard in term.flashcards.all():%0A            ItemRelation.objects.get_or_create(%0A                parent_id=parent_id,%0A                child_id=flashcard.item_id,%0A                visible=True%0A            )%0A%0A%0Adef move_context_structure(apps, schema_editor):%0A    Context = apps.get_model('proso_flashcards', %22Context%22)%0A    ItemRelation = apps.get_model('proso_models', 'ItemRelation')%0A    contexts = Context.objects.prefetch_related('flashcards').all()%0A    for context in contexts:%0A        parent_id = context.item_id%0A        for flashcard in context.flashcards.all():%0A            ItemRelation.objects.get_or_create(%0A                parent_id=parent_id,%0A                child_id=flashcard.item_id,%0A                visible=True%0A            )%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('proso_models', '0014_auto_item_children'),%0A        ('proso_flashcards', '0012_auto_django_python3_conversion'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(drop_all_environment_relations),%0A        migrations.RunPython(move_category_structure),%0A        migrations.RunPython(move_term_structure),%0A        migrations.RunPython(move_context_structure),%0A    %5D%0A

move all information about structure to items