111 lines
7.1 KiB
Python
111 lines
7.1 KiB
Python
|
|
from django.db import migrations, models
|
||
|
|
|
||
|
|
|
||
|
|
class Migration(migrations.Migration):
|
||
|
|
|
||
|
|
dependencies = [
|
||
|
|
("location_data", "0010_blocksubdivision_elbow_plot"),
|
||
|
|
]
|
||
|
|
|
||
|
|
operations = [
|
||
|
|
migrations.CreateModel(
|
||
|
|
name="AnalysisGridCell",
|
||
|
|
fields=[
|
||
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||
|
|
("block_code", models.CharField(blank=True, db_index=True, default="", help_text="شناسه بلوکی که این سلول به آن تعلق دارد.", max_length=64)),
|
||
|
|
("cell_code", models.CharField(help_text="شناسه یکتای سلول تحلیل.", max_length=128, unique=True)),
|
||
|
|
("chunk_size_sqm", models.PositiveIntegerField(db_index=True, default=900, help_text="اندازه سلول تحلیل به متر مربع.")),
|
||
|
|
("geometry", models.JSONField(blank=True, default=dict, help_text="هندسه سلول به صورت GeoJSON polygon یا ساختار مشابه.")),
|
||
|
|
("centroid_lat", models.DecimalField(db_index=True, decimal_places=6, help_text="عرض جغرافیایی مرکز سلول.", max_digits=9)),
|
||
|
|
("centroid_lon", models.DecimalField(db_index=True, decimal_places=6, help_text="طول جغرافیایی مرکز سلول.", max_digits=9)),
|
||
|
|
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
||
|
|
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="analysis_grid_cells", to="location_data.blocksubdivision")),
|
||
|
|
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="analysis_grid_cells", to="location_data.soillocation")),
|
||
|
|
],
|
||
|
|
options={
|
||
|
|
"verbose_name": "analysis grid cell",
|
||
|
|
"verbose_name_plural": "analysis grid cells",
|
||
|
|
"ordering": ["soil_location", "block_code", "cell_code"],
|
||
|
|
},
|
||
|
|
),
|
||
|
|
migrations.CreateModel(
|
||
|
|
name="RemoteSensingRun",
|
||
|
|
fields=[
|
||
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||
|
|
("block_code", models.CharField(blank=True, db_index=True, default="", help_text="شناسه بلوکی که این run برای آن اجرا شده است.", max_length=64)),
|
||
|
|
("provider", models.CharField(default="openeo", help_text="ارائهدهنده داده سنجشازدور.", max_length=64)),
|
||
|
|
("chunk_size_sqm", models.PositiveIntegerField(default=900, help_text="اندازه هر سلول تحلیل به متر مربع.")),
|
||
|
|
("temporal_start", models.DateField(blank=True, null=True)),
|
||
|
|
("temporal_end", models.DateField(blank=True, null=True)),
|
||
|
|
("status", models.CharField(choices=[("pending", "Pending"), ("running", "Running"), ("success", "Success"), ("failure", "Failure")], db_index=True, default="pending", max_length=16)),
|
||
|
|
("metadata", models.JSONField(blank=True, default=dict)),
|
||
|
|
("error_message", models.TextField(blank=True, default="")),
|
||
|
|
("started_at", models.DateTimeField(blank=True, null=True)),
|
||
|
|
("finished_at", models.DateTimeField(blank=True, null=True)),
|
||
|
|
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
||
|
|
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="remote_sensing_runs", to="location_data.blocksubdivision")),
|
||
|
|
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="remote_sensing_runs", to="location_data.soillocation")),
|
||
|
|
],
|
||
|
|
options={
|
||
|
|
"verbose_name": "remote sensing run",
|
||
|
|
"verbose_name_plural": "remote sensing runs",
|
||
|
|
"ordering": ["-created_at", "-id"],
|
||
|
|
},
|
||
|
|
),
|
||
|
|
migrations.CreateModel(
|
||
|
|
name="AnalysisGridObservation",
|
||
|
|
fields=[
|
||
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||
|
|
("temporal_start", models.DateField(db_index=True)),
|
||
|
|
("temporal_end", models.DateField(db_index=True)),
|
||
|
|
("ndvi", models.FloatField(blank=True, null=True)),
|
||
|
|
("ndwi", models.FloatField(blank=True, null=True)),
|
||
|
|
("lst_c", models.FloatField(blank=True, null=True)),
|
||
|
|
("soil_vv", models.FloatField(blank=True, null=True)),
|
||
|
|
("soil_vv_db", models.FloatField(blank=True, null=True)),
|
||
|
|
("dem_m", models.FloatField(blank=True, null=True)),
|
||
|
|
("slope_deg", models.FloatField(blank=True, null=True)),
|
||
|
|
("metadata", models.JSONField(blank=True, default=dict)),
|
||
|
|
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
||
|
|
("cell", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="observations", to="location_data.analysisgridcell")),
|
||
|
|
("run", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="observations", to="location_data.remotesensingrun")),
|
||
|
|
],
|
||
|
|
options={
|
||
|
|
"verbose_name": "analysis grid observation",
|
||
|
|
"verbose_name_plural": "analysis grid observations",
|
||
|
|
"ordering": ["-temporal_start", "-temporal_end", "-id"],
|
||
|
|
},
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="analysisgridcell",
|
||
|
|
index=models.Index(fields=["soil_location", "block_code"], name="grid_cell_loc_block_idx"),
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="analysisgridcell",
|
||
|
|
index=models.Index(fields=["soil_location", "chunk_size_sqm"], name="grid_cell_loc_chunk_idx"),
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="remotesensingrun",
|
||
|
|
index=models.Index(fields=["soil_location", "status", "created_at"], name="rs_run_loc_status_created_idx"),
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="remotesensingrun",
|
||
|
|
index=models.Index(fields=["block_code", "created_at"], name="rs_run_block_created_idx"),
|
||
|
|
),
|
||
|
|
migrations.AddConstraint(
|
||
|
|
model_name="analysisgridobservation",
|
||
|
|
constraint=models.UniqueConstraint(fields=("cell", "temporal_start", "temporal_end"), name="grid_obs_unique_cell_temporal_range"),
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="analysisgridobservation",
|
||
|
|
index=models.Index(fields=["cell", "temporal_start", "temporal_end"], name="grid_obs_cell_temporal_idx"),
|
||
|
|
),
|
||
|
|
migrations.AddIndex(
|
||
|
|
model_name="analysisgridobservation",
|
||
|
|
index=models.Index(fields=["temporal_start", "temporal_end"], name="grid_obs_temporal_idx"),
|
||
|
|
),
|
||
|
|
]
|