# Generated by Django 2.2.20 on 2021-08-20 07:33

from django.db import migrations


def remove_rcce_tag(apps, schema_editor):
    """
    Remove RCCE tag and change it to combination of CEA and HEALTH_PUBLIC
    """
    # NOTE: This is broken, keeping it as it is already deployed to staging.
    return

    # Hardcode enum value present this time
    RCCE = 14
    HEALTH_PUBLIC = 4
    CEA = 2

    Project = apps.get_model('deployments', 'Project')
    # get only the project that have `RCCE` tag
    projects = Project.objects.filter(secondary_sectors__contains=[RCCE])
    for project in projects:
        project.secondary_sectors.remove(RCCE)
        project.secondary_sectors.extend([HEALTH_PUBLIC, CEA])
        project.save(update_fields=['secondary_sectors'])


class Migration(migrations.Migration):

    dependencies = [
        ('deployments', '0037_project_modified_by'),
    ]

    operations = [
        migrations.RunPython(
            remove_rcce_tag,
            reverse_code=migrations.RunPython.noop,
        ),
    ]
