# Generated by Django 4.2.2 on 2025-09-08 19:34

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('products', '0001_initial'),
        ('customermanagement', '0002_passwordresettoken'),
    ]

    operations = [
        migrations.CreateModel(
            name='CustomerDevice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('serial_number', models.CharField(db_index=True, help_text='Physical device serial; must be globally unique.', max_length=100, unique=True)),
                ('device_label', models.CharField(help_text='User-defined label; must be unique per customer.', max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('customer', models.ForeignKey(help_text='Owner of the device.', on_delete=django.db.models.deletion.CASCADE, related_name='devices', to='customermanagement.customer')),
                ('product', models.ForeignKey(help_text='Device type from the product catalog.', on_delete=django.db.models.deletion.PROTECT, related_name='customer_devices', to='products.product')),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['customer'], name='mydeviceman_custome_14f4c9_idx'), models.Index(fields=['product'], name='mydeviceman_product_89a431_idx')],
            },
        ),
        migrations.AddConstraint(
            model_name='customerdevice',
            constraint=models.UniqueConstraint(fields=('customer', 'device_label'), name='uniq_device_label_per_customer'),
        ),
    ]
