# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2018-03-14 17:28
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


def set_defaults(apps, schema_editor):
    Dataset = apps.get_model('network', 'Dataset')
    Experiment = apps.get_model('network', 'Experiment')

    default_dataset = Dataset.objects.all()[0]
    default_experiment = Experiment.objects.all()[0]

    MetadataRec = apps.get_model('network', 'MetadataRec')
    PrimaryDataRec = apps.get_model('network', 'PrimaryDataRec')

    for metadata_rec in MetadataRec.objects.all():
        metadata_rec.personal_experiment = default_experiment
        metadata_rec.save()

    for primary_data_rec in PrimaryDataRec.objects.all():
        primary_data_rec.dataset = default_dataset
        primary_data_rec.personal_experiment = default_experiment
        primary_data_rec.personal_dataset = default_dataset
        primary_data_rec.save()


class Migration(migrations.Migration):

    dependencies = [
        ('network', '0015_auto_20180314_1318'),
    ]

    operations = [

        migrations.RunPython(set_defaults),

        migrations.AlterField(
            model_name='metadatarec',
            name='personal_experiment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metadatarec_owned', to='network.Experiment'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_recommended', to='network.Dataset'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='personal_dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_owned', to='network.Dataset'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='personal_experiment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_owned', to='network.Experiment'),
        ),
    ]

# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2018-03-14 17:28
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


def set_defaults(apps, schema_editor):
    Dataset = apps.get_model('network', 'Dataset')
    Experiment = apps.get_model('network', 'Experiment')

    default_dataset = Dataset.objects.all()[0]
    default_experiment = Experiment.objects.all()[0]

    MetadataRec = apps.get_model('network', 'MetadataRec')
    PrimaryDataRec = apps.get_model('network', 'PrimaryDataRec')

    for metadata_rec in MetadataRec.objects.all():
        metadata_rec.personal_experiment = default_experiment
        metadata_rec.save()

    for primary_data_rec in PrimaryDataRec.objects.all():
        primary_data_rec.dataset = default_dataset
        primary_data_rec.personal_experiment = default_experiment
        primary_data_rec.personal_dataset = default_dataset
        primary_data_rec.save()


class Migration(migrations.Migration):

    dependencies = [
        ('network', '0015_auto_20180314_1318'),
    ]

    operations = [

        migrations.RunPython(set_defaults),

        migrations.AlterField(
            model_name='metadatarec',
            name='personal_experiment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metadatarec_owned', to='network.Experiment'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_recommended', to='network.Dataset'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='personal_dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_owned', to='network.Dataset'),
        ),
        migrations.AlterField(
            model_name='primarydatarec',
            name='personal_experiment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='primarydatarec_owned', to='network.Experiment'),
        ),
    ]

# -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2018-03-14 17:28