# Generated by Django 4.2.8 on 2026-02-05 15:29

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

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

    operations = [
        migrations.AlterModelOptions(
            name="nomenclature",
            options={"ordering": ["sort_order", "code"]},
        ),
        migrations.AlterModelOptions(
            name="nomenclaturefield",
            options={"ordering": ["sort_order", "key"]},
        ),
        migrations.AddField(
            model_name="nomenclature",
            name="display_field",
            field=models.CharField(
                blank=True,
                default="name",
                help_text="Key of the NomenclatureField to use as dropdown label (for lookup kind)",
                max_length=50,
            ),
        ),
        migrations.AddField(
            model_name="nomenclature",
            name="kind",
            field=models.CharField(
                choices=[("lookup", "Lookup Table"), ("field", "Custom Field")],
                default="lookup",
                max_length=10,
            ),
        ),
        migrations.AddField(
            model_name="nomenclature",
            name="sort_order",
            field=models.IntegerField(default=0),
        ),
        migrations.AddField(
            model_name="nomenclaturefield",
            name="choices",
            field=models.JSONField(
                blank=True,
                help_text='List of allowed values for choice type, e.g. ["Red","Green","Blue"]',
                null=True,
            ),
        ),
        migrations.AddField(
            model_name="nomenclaturefield",
            name="label",
            field=models.CharField(blank=True, max_length=100),
        ),
        migrations.AddField(
            model_name="nomenclaturefield",
            name="required",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="nomenclaturefield",
            name="sort_order",
            field=models.IntegerField(default=0),
        ),
        migrations.AlterField(
            model_name="nomenclaturefield",
            name="nomenclature",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="fields",
                to="nomenclatures.nomenclature",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="nomenclaturefield",
            unique_together={("nomenclature", "key")},
        ),
        migrations.CreateModel(
            name="NomenclatureEntry",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("data", models.JSONField(default=dict)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "nomenclature",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="entries",
                        to="nomenclatures.nomenclature",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Nomenclature entries",
                "ordering": ["id"],
            },
        ),
    ]
