# Generated by Django 5.2 on 2025-05-21 09:35

import django_extensions.db.fields
from django.db import migrations


def populate_slugs(apps, schema_editor):
    if schema_editor:
        pass
    Category = apps.get_model("core", "Category")
    for category in Category.objects.all():
        try:
            if not category.slug:
                category.save()
        except AttributeError:
            pass


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0021_rename_name_ar_ar_attribute_name_ar_ar_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="category",
            name="slug",
            field=django_extensions.db.fields.AutoSlugField(
                allow_unicode=True, blank=True, editable=False, null=True, populate_from=("uuid", "name"), unique=True
            ),
        ),
        migrations.RunPython(populate_slugs, reverse_code=migrations.RunPython.noop),
    ]
