Files
Ai/location_data/migrations/0012_remote_sensing_subdivision_models.py
T

66 lines
3.8 KiB
Python
Raw Normal View History

2026-05-09 16:55:06 +03:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("location_data", "0011_remote_sensing_models"),
]
operations = [
migrations.CreateModel(
name="RemoteSensingSubdivisionResult",
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="", max_length=64)),
("chunk_size_sqm", models.PositiveIntegerField(default=900)),
("temporal_start", models.DateField(db_index=True)),
("temporal_end", models.DateField(db_index=True)),
("cluster_count", models.PositiveIntegerField(default=0)),
("selected_features", models.JSONField(blank=True, default=list)),
("skipped_cell_codes", models.JSONField(blank=True, default=list)),
("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)),
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="remote_sensing_subdivision_results", to="location_data.blocksubdivision")),
("run", models.OneToOneField(on_delete=models.deletion.CASCADE, related_name="subdivision_result", to="location_data.remotesensingrun")),
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="remote_sensing_subdivision_results", to="location_data.soillocation")),
],
options={
"verbose_name": "remote sensing subdivision result",
"verbose_name_plural": "remote sensing subdivision results",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="RemoteSensingClusterAssignment",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("cluster_label", models.PositiveIntegerField(db_index=True)),
("raw_feature_values", models.JSONField(blank=True, default=dict)),
("scaled_feature_values", 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="cluster_assignments", to="location_data.analysisgridcell")),
("result", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="assignments", to="location_data.remotesensingsubdivisionresult")),
],
options={
"verbose_name": "remote sensing cluster assignment",
"verbose_name_plural": "remote sensing cluster assignments",
"ordering": ["cluster_label", "cell__cell_code"],
},
),
migrations.AddIndex(
model_name="remotesensingsubdivisionresult",
index=models.Index(fields=["soil_location", "block_code", "temporal_start", "temporal_end"], name="rs_subdiv_result_lookup_idx"),
),
migrations.AddConstraint(
model_name="remotesensingclusterassignment",
constraint=models.UniqueConstraint(fields=("result", "cell"), name="rs_cluster_assign_unique_result_cell"),
),
migrations.AddIndex(
model_name="remotesensingclusterassignment",
index=models.Index(fields=["result", "cluster_label"], name="rs_cluster_assign_result_label_idx"),
),
]