# Generated by Django 3.1.5 on 2021-02-17 11:04

from django.db import migrations

import saleor.core.db.fields
import saleor.core.utils.editorjs


def update_empty_description_field(apps, schema_editor):
    Category = apps.get_model("product", "Category")
    CategoryTranslation = apps.get_model("product", "CategoryTranslation")
    Collection = apps.get_model("product", "Collection")
    CollectionTranslation = apps.get_model("product", "CollectionTranslation")
    Product = apps.get_model("product", "Product")
    ProductTranslation = apps.get_model("product", "ProductTranslation")

    models = [
        Category,
        CategoryTranslation,
        Collection,
        CollectionTranslation,
        Product,
        ProductTranslation,
    ]

    for model in models:
        model.objects.filter(description={}).update(description=None)


class Migration(migrations.Migration):

    dependencies = [
        ("product", "0140_auto_20210125_0905"),
    ]

    operations = [
        migrations.AlterField(
            model_name="category",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.AlterField(
            model_name="categorytranslation",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.AlterField(
            model_name="collection",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.AlterField(
            model_name="collectiontranslation",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.AlterField(
            model_name="product",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.AlterField(
            model_name="producttranslation",
            name="description",
            field=saleor.core.db.fields.SanitizedJSONField(
                blank=True,
                null=True,
                sanitizer=saleor.core.utils.editorjs.clean_editor_js,
            ),
        ),
        migrations.RunPython(
            update_empty_description_field,
            migrations.RunPython.noop,
        ),
    ]

[((91, 8, 94, 9), 'django.db.migrations.RunPython', 'migrations.RunPython', ({(92, 12, 92, 42): 'update_empty_description_field', (93, 12, 93, 37): 'migrations.RunPython.noop'}, {}), '(update_empty_description_field, migrations.RunPython.noop)', False, 'from django.db import migrations\n')]