# Generated by Django 4.2.2 on 2025-09-10 06:35

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('fieldmanagement', '0001_initial'),
        ('buyers', '0001_initial'),
        ('mydevicemanagement', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Result',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('batch_number', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True)),
                ('crop_type', models.CharField(max_length=100)),
                ('crop_temperature', models.FloatField(blank=True, null=True)),
                ('crop_weight', models.FloatField(blank=True, null=True)),
                ('moisture_level', models.FloatField()),
                ('moisture_threshold', models.FloatField()),
                ('humidity', models.FloatField(blank=True, null=True)),
                ('weather_temperature', models.FloatField(blank=True, null=True)),
                ('pressure', models.FloatField(blank=True, null=True)),
                ('weather_description', models.CharField(blank=True, max_length=255)),
                ('visibility', models.FloatField(blank=True, null=True)),
                ('wind_speed', models.FloatField(blank=True, null=True)),
                ('wind_direction', models.CharField(blank=True, max_length=50)),
                ('wind_gusts', models.FloatField(blank=True, null=True)),
                ('cloud_coverage', models.FloatField(blank=True, null=True)),
                ('uv_index', models.FloatField(blank=True, null=True)),
                ('gps_lat', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
                ('gps_lon', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
                ('sample_image', models.ImageField(blank=True, null=True, upload_to='result_samples/', validators=[django.core.validators.FileExtensionValidator(['png'])])),
                ('reading_datetime', models.DateTimeField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('buyer', models.ForeignKey(blank=True, help_text='Buyer linked to this result (optional).', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='results', to='buyers.customerbuyer')),
                ('device', models.ForeignKey(help_text='Device that recorded this result (must belong to the customer).', on_delete=django.db.models.deletion.PROTECT, related_name='results', to='mydevicemanagement.customerdevice')),
                ('field', models.ForeignKey(blank=True, help_text='Field where the sample was taken (optional).', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='results', to='fieldmanagement.customerfield')),
            ],
            options={
                'ordering': ['-reading_datetime', '-created_at'],
                'indexes': [models.Index(fields=['device'], name='results_res_device__5b727a_idx'), models.Index(fields=['reading_datetime'], name='results_res_reading_bdfc0f_idx')],
            },
        ),
    ]
