# Generated by Django 3.2.11 on 2022-07-19 21:55

from django.db import migrations
from django.db.models import F
from edc_reportable import PERCENT


def update_new_egfr_drop_field(apps, schema_editor):
    rft_model_cls = apps.get_model("meta_subject.bloodresultsrft")
    rft_model_cls.objects.all().update(
        egfr_drop_value=F("egfr_percent_change"), egfr_drop_units=PERCENT
    )
    rft_model_cls = apps.get_model("meta_subject.historicalbloodresultsrft")
    rft_model_cls.objects.all().update(
        egfr_drop_value=F("egfr_percent_change"), egfr_drop_units=PERCENT
    )


class Migration(migrations.Migration):

    dependencies = [
        ("meta_subject", "0127_auto_20220720_0053"),
    ]

    operations = [migrations.RunPython(update_new_egfr_drop_field)]
