# Generated by Django 3.0.9 on 2020-08-26 12:49

from django.db import migrations


def cleanup_crf_metadata(apps, schema_editor):
    crfmetadata_model_cls = apps.get_model("edc_metadata.crfmetadata")

    model = "inte_subject.reasonforvisit"
    crfmetadata_model_cls.objects.filter(model=model).delete()

    model = "inte_subject.carestatus"
    crfmetadata_model_cls.objects.filter(model=model).delete()

    model = "inte_subject.healtheconomics"
    crfmetadata_model_cls.objects.filter(model=model).delete()

    old_model = "inte_subject.carestatusbaseline"
    new_model = "inte_subject.clinicalreviewbaseline"
    crfmetadata_model_cls.objects.filter(model=old_model).update(model=new_model)

    old_model = "inte_subject.investigations"
    new_model = "inte_subject.clinicalreview"
    crfmetadata_model_cls.objects.filter(model=old_model).update(model=new_model)


class Migration(migrations.Migration):

    dependencies = [
        ("inte_subject", "0039_auto_20200824_0225"),
    ]

    operations = [migrations.RunPython(cleanup_crf_metadata)]
