UPDATE
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CropArea',
|
||||
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)),
|
||||
('geometry', models.JSONField(default=dict)),
|
||||
('points', models.JSONField(default=list)),
|
||||
('center', models.JSONField(default=dict)),
|
||||
('area_sqm', models.FloatField()),
|
||||
('area_hectares', models.FloatField()),
|
||||
('chunk_area_sqm', models.FloatField()),
|
||||
('zone_count', models.PositiveIntegerField(default=0)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'crop_areas',
|
||||
'ordering': ['-created_at', '-id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CropZone',
|
||||
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)),
|
||||
('zone_id', models.CharField(max_length=64)),
|
||||
('geometry', models.JSONField(default=dict)),
|
||||
('points', models.JSONField(default=list)),
|
||||
('center', models.JSONField(default=dict)),
|
||||
('area_sqm', models.FloatField()),
|
||||
('area_hectares', models.FloatField()),
|
||||
('sequence', models.PositiveIntegerField()),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('crop_area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='zones', to='crop_zoning.croparea')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'crop_zones',
|
||||
'ordering': ['sequence', 'id'],
|
||||
'constraints': [models.UniqueConstraint(fields=('crop_area', 'zone_id'), name='unique_crop_area_zone_id')],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,99 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("crop_zoning", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="CropProduct",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("product_id", models.CharField(max_length=64, unique=True)),
|
||||
("label", models.CharField(max_length=255)),
|
||||
("color", models.CharField(max_length=32)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_products",
|
||||
"ordering": ["id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneCultivationRiskLayer",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("level", models.CharField(choices=[("low", "Low"), ("medium", "Medium"), ("high", "High")], max_length=16)),
|
||||
("color", models.CharField(max_length=32)),
|
||||
("crop_zone", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="cultivation_risk_layer", to="crop_zoning.cropzone")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_cultivation_risk_layers",
|
||||
"ordering": ["crop_zone_id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneRecommendation",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("match_percent", models.PositiveIntegerField()),
|
||||
("water_need", models.CharField(max_length=128)),
|
||||
("estimated_profit", models.CharField(max_length=128)),
|
||||
("reason", models.TextField(blank=True, default="")),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("crop_zone", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="recommendation", to="crop_zoning.cropzone")),
|
||||
("product", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="zone_recommendations", to="crop_zoning.cropproduct")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_recommendations",
|
||||
"ordering": ["crop_zone_id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneSoilQualityLayer",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("level", models.CharField(choices=[("low", "Low"), ("medium", "Medium"), ("high", "High")], max_length=16)),
|
||||
("score", models.PositiveIntegerField()),
|
||||
("color", models.CharField(max_length=32)),
|
||||
("crop_zone", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="soil_quality_layer", to="crop_zoning.cropzone")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_soil_quality_layers",
|
||||
"ordering": ["crop_zone_id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneWaterNeedLayer",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("level", models.CharField(choices=[("low", "Low"), ("medium", "Medium"), ("high", "High")], max_length=16)),
|
||||
("value", models.CharField(max_length=128)),
|
||||
("color", models.CharField(max_length=32)),
|
||||
("crop_zone", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="water_need_layer", to="crop_zoning.cropzone")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_water_need_layers",
|
||||
"ordering": ["crop_zone_id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneCriteria",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("name", models.CharField(max_length=128)),
|
||||
("value", models.PositiveIntegerField()),
|
||||
("sequence", models.PositiveIntegerField(default=0)),
|
||||
("recommendation", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="criteria", to="crop_zoning.cropzonerecommendation")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_criteria",
|
||||
"ordering": ["sequence", "id"],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,49 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("crop_zoning", "0002_crop_zoning_mock_schema"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="cropzone",
|
||||
name="processing_error",
|
||||
field=models.TextField(blank=True, default=""),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="cropzone",
|
||||
name="processing_status",
|
||||
field=models.CharField(
|
||||
choices=[("pending", "Pending"), ("processing", "Processing"), ("completed", "Completed"), ("failed", "Failed")],
|
||||
default="pending",
|
||||
max_length=16,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="cropzone",
|
||||
name="task_id",
|
||||
field=models.CharField(blank=True, default="", max_length=255),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CropZoneAnalysis",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("source", models.CharField(blank=True, default="", max_length=64)),
|
||||
("external_record_id", models.CharField(blank=True, default="", max_length=64)),
|
||||
("latitude", models.DecimalField(blank=True, decimal_places=6, max_digits=10, null=True)),
|
||||
("longitude", models.DecimalField(blank=True, decimal_places=6, max_digits=10, null=True)),
|
||||
("raw_response", models.JSONField(blank=True, default=dict)),
|
||||
("depths", models.JSONField(blank=True, default=list)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("crop_zone", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="analysis", to="crop_zoning.cropzone")),
|
||||
],
|
||||
options={
|
||||
"db_table": "crop_zone_analyses",
|
||||
"ordering": ["crop_zone_id"],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("farm_hub", "0002_seed_default_catalog"),
|
||||
("crop_zoning", "0003_zone_processing_and_analysis"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="croparea",
|
||||
name="farm",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="crop_areas",
|
||||
to="farm_hub.farmhub",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user