# Generated by Django 2.2.10 on 2020-05-20 13:10

from django.db import migrations

def migrate_s_to_supp(apps, schema_editor):
    BiosourceSamplingProcess = apps.get_model("majora2", "BiosourceSamplingProcess")
    COGUK_BiosourceSamplingProcessSupplement = apps.get_model("majora2", "COGUK_BiosourceSamplingProcessSupplement")
    for collection in BiosourceSamplingProcess.objects.all():
        if not hasattr(collection, "coguk_supp"):
            # This shouldnt happen but w/e
            c = COGUK_BiosourceSamplingProcessSupplement(sampling=collection)
            c.save()
        else:
            c = collection.coguk_supp
        if collection.sampling_strategy == "SURVEILLANCE":
            c.is_surveillance = True
            c.save()

class Migration(migrations.Migration):

    dependencies = [
        ('majora2', '0085_add_supp_to_collections'),
    ]

    operations = [
        migrations.RunPython(migrate_s_to_supp),
    ]
