# Generated by Django 5.2.12 on 2026-03-19 15:01 import django.db.models.deletion import uuid from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name="FarmType", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)), ("name", models.CharField(db_index=True, max_length=255, unique=True)), ("description", models.TextField(blank=True, default="")), ("metadata", models.JSONField(blank=True, default=dict)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ], options={ "db_table": "farm_types", "ordering": ["name"], }, ), migrations.CreateModel( name="FarmHub", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("farm_uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)), ("name", models.CharField(max_length=255)), ("is_active", models.BooleanField(default=True)), ("customization", models.JSONField(blank=True, default=dict)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "farm_type", models.ForeignKey( on_delete=django.db.models.deletion.PROTECT, related_name="farms", to="farm_hub.farmtype", ), ), ( "owner", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="farm_hubs", to=settings.AUTH_USER_MODEL, ), ), ], options={ "db_table": "farm_hubs", "ordering": ["-created_at"], }, ), migrations.CreateModel( name="Product", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)), ("name", models.CharField(db_index=True, max_length=255)), ("description", models.TextField(blank=True, default="")), ("metadata", models.JSONField(blank=True, default=dict)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "farm_type", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="products", to="farm_hub.farmtype", ), ), ], options={ "db_table": "products", "ordering": ["name"], }, ), migrations.CreateModel( name="FarmSensor", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)), ("name", models.CharField(max_length=255)), ("sensor_type", models.CharField(blank=True, default="", max_length=255)), ("is_active", models.BooleanField(default=True)), ("specifications", models.JSONField(blank=True, default=dict)), ("power_source", models.JSONField(blank=True, default=dict)), ("customization", models.JSONField(blank=True, default=dict)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "farm", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="sensors", to="farm_hub.farmhub", ), ), ], options={ "db_table": "farm_sensors", "ordering": ["-created_at"], }, ), migrations.AddField( model_name="farmhub", name="products", field=models.ManyToManyField(blank=True, related_name="farms", to="farm_hub.product"), ), migrations.AddConstraint( model_name="product", constraint=models.UniqueConstraint(fields=("farm_type", "name"), name="unique_product_per_farm_type"), ), ]