# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-01-14 17:40

from django.db import migrations
from django.db.models import OuterRef, Subquery


def forwards_func(apps, schema_editor):
    """Migrate ``Project.documentation_type`` to ``Version.documentation_type``."""
    Version = apps.get_model('builds', 'Version')
    Project = apps.get_model('projects', 'Project')

    Version.objects.all().update(
        documentation_type=Subquery(
            Project.objects
            .filter(pk=OuterRef('project'))
            .values('documentation_type')[:1]
        ),
    )


class Migration(migrations.Migration):

    dependencies = [
        ('builds', '0013_version_documentation_type'),
    ]

    operations = [
        migrations.RunPython(forwards_func),
    ]

Migrate documentation_type from Project to Version
Migrate documentation_type from Project to Version
