# Generated by Codex for netbox_unifi_sync

from django.db import migrations, models


def set_default_asset_tag_patterns(apps, schema_editor):
    GlobalSyncSettings = apps.get_model("netbox_unifi_sync", "GlobalSyncSettings")
    for row in GlobalSyncSettings.objects.all():
        if not row.asset_tag_patterns:
            row.asset_tag_patterns = [r"[-_]?(A?ID\d+)$"]
            row.save(update_fields=["asset_tag_patterns", "updated"])


class Migration(migrations.Migration):

    dependencies = [
        ("netbox_unifi_sync", "0001_initial"),
    ]

    operations = [
        migrations.AddField(
            model_name="globalsyncsettings",
            name="asset_tag_enabled",
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name="globalsyncsettings",
            name="asset_tag_patterns",
            field=models.JSONField(
                blank=True,
                default=list,
                help_text="JSON list of regex patterns. First match wins. Use capture group for extracted value.",
            ),
        ),
        migrations.AddField(
            model_name="globalsyncsettings",
            name="asset_tag_uppercase",
            field=models.BooleanField(default=True),
        ),
        migrations.RunPython(set_default_asset_tag_patterns, migrations.RunPython.noop),
    ]
