# Generated by Django 3.2.13 on 2022-06-20 14:07 from django.db import migrations from core_images.consts.fallbacks import GRAS_ARTISTS_FALLBACK_URLS # first data migration to fill the base with current fallbacks. # TODO: make it empty in future releases when get rid of fallbacks constant def go_forward(apps, schema_editor): FallbackUrl = apps.get_model("core_images", "FallbackUrl") # noqa for k, v in GRAS_ARTISTS_FALLBACK_URLS.items(): FallbackUrl.objects.update_or_create(gras_id=k, defaults={"url": v}) def go_back(apps, schema_editor): FallbackUrl = apps.get_model("core_images", "FallbackUrl") # noqa FallbackUrl.objects.filter( gras_id__in=list(GRAS_ARTISTS_FALLBACK_URLS.keys()) ).delete() class Migration(migrations.Migration): dependencies = [ ("core_images", "0001_initial"), ] operations = [migrations.RunPython(go_forward, go_back)]