# Generated by Django 5.2.8 on 2025-12-06 15:03

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="RFID",
            fields=[
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "label_id",
                    models.AutoField(
                        db_column="label_id", primary_key=True, serialize=False
                    ),
                ),
                (
                    "rfid",
                    models.CharField(
                        max_length=255,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]+$",
                                message="RFID must be hexadecimal digits",
                            )
                        ],
                        verbose_name="RFID",
                    ),
                ),
                (
                    "reversed_uid",
                    models.CharField(
                        blank=True,
                        default="",
                        editable=False,
                        help_text="UID value stored with opposite endianness for reference.",
                        max_length=255,
                        verbose_name="Reversed UID",
                    ),
                ),
                (
                    "custom_label",
                    models.CharField(
                        blank=True,
                        help_text="Optional custom label for this RFID.",
                        max_length=32,
                        verbose_name="Custom Label",
                    ),
                ),
                (
                    "key_a",
                    models.CharField(
                        default="FFFFFFFFFFFF",
                        max_length=12,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]{12}$",
                                message="Key must be 12 hexadecimal digits",
                            )
                        ],
                        verbose_name="Key A",
                    ),
                ),
                (
                    "key_b",
                    models.CharField(
                        default="FFFFFFFFFFFF",
                        max_length=12,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]{12}$",
                                message="Key must be 12 hexadecimal digits",
                            )
                        ],
                        verbose_name="Key B",
                    ),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True, default=list, help_text="Sector and block data"
                    ),
                ),
                ("key_a_verified", models.BooleanField(default=False)),
                ("key_b_verified", models.BooleanField(default=False)),
                ("allowed", models.BooleanField(default=True)),
                (
                    "external_command",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="Optional command executed during validation.",
                    ),
                ),
                (
                    "post_auth_command",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="Optional command executed after successful validation.",
                    ),
                ),
                (
                    "expiry_date",
                    models.DateField(
                        blank=True,
                        help_text="Optional expiration date for this RFID card.",
                        null=True,
                    ),
                ),
                (
                    "color",
                    models.CharField(
                        choices=[
                            ("B", "Black"),
                            ("W", "White"),
                            ("U", "Blue"),
                            ("R", "Red"),
                            ("G", "Green"),
                        ],
                        default="B",
                        max_length=1,
                    ),
                ),
                (
                    "kind",
                    models.CharField(
                        choices=[("CLASSIC", "MIFARE Classic"), ("NTAG215", "NTAG215")],
                        default="CLASSIC",
                        max_length=20,
                        verbose_name="Kind",
                    ),
                ),
                (
                    "endianness",
                    models.CharField(
                        choices=[("BIG", "Big endian"), ("LITTLE", "Little endian")],
                        default="BIG",
                        max_length=6,
                    ),
                ),
                ("released", models.BooleanField(default=False)),
                ("added_on", models.DateTimeField(auto_now_add=True)),
                ("last_seen_on", models.DateTimeField(blank=True, null=True)),
            ],
            options={
                "verbose_name": "RFID",
                "verbose_name_plural": "RFIDs",
                "db_table": "core_rfid",
            },
        ),
    ]
