# Generated by Django 3.1.7 on 2021-03-02 11:48

from django.db import migrations


def postgres_migration_prep(apps, schema_editor):
    model = apps.get_model("RIGS", "Event")
    for field in ["auth_request_to", "collector", "description", "notes", "purchase_order"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "EventAuthorisation")
    for field in ["account_code", "uni_id"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "EventChecklist")
    for field in ["extinguishers_location", "hs_location", "w1_description", "w2_description", "w3_description"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "EventItem")
    for field in ["description"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "Organisation")
    for field in ["address", "email", "notes", "phone"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "Payment")
    for field in ["method"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "Person")
    for field in ["address", "email", "notes", "phone"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "Profile")
    for field in ["phone"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "RiskAssessment")
    for field in ["general_notes", "persons_responsible_structures", "power_notes", "rigging_plan", "sound_notes"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)
    model = apps.get_model("RIGS", "Venue")
    for field in ["address", "email", "notes", "phone"]:
        filter_param = {"{}__isnull".format(field): True}
        update_param = {field: ""}
        model.objects.filter(**filter_param).update(**update_param)


class Migration(migrations.Migration):

    dependencies = [
        ('RIGS', '0039_auto_20210123_1910'),
    ]

    operations = [
        migrations.RunPython(postgres_migration_prep, migrations.RunPython.noop)
    ]
