# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-03-12 11:20
from __future__ import unicode_literals

from django.db import migrations


def add_scope(apps, schema_editor):
    ContentType = apps.get_model('contenttypes', 'ContentType')
    Project = apps.get_model('structure', 'Project')
    AggregateResourceCount = apps.get_model('marketplace', 'aggregateresourcecount')

    project_ct = ContentType.objects.get_for_model(Project)

    for row in AggregateResourceCount.objects.all():
        row.content_type = project_ct
        row.object_id = row.project_id
        row.save()


class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('marketplace', '0062_add_scope_to_resource_count'),
    ]

    operations = [
        migrations.RunPython(add_scope)
    ]
