Files

93 lines
5.4 KiB
Python
Raw Permalink Normal View History

2026-05-11 04:38:44 +03:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("location_data", "0017_remotesensingclusterblock"),
]
operations = [
migrations.CreateModel(
name="RemoteSensingSubdivisionOption",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("requested_k", models.PositiveIntegerField(db_index=True)),
("effective_cluster_count", models.PositiveIntegerField(default=0)),
("is_active", models.BooleanField(db_index=True, default=False)),
("is_recommended", models.BooleanField(db_index=True, default=False)),
("selection_source", models.CharField(default="system", help_text="منشا انتخاب این گزینه؛ مثل system یا user.", max_length=32)),
("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)),
("result", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="options", to="location_data.remotesensingsubdivisionresult")),
],
options={
"verbose_name": "remote sensing subdivision option",
"verbose_name_plural": "remote sensing subdivision options",
"ordering": ["result", "requested_k", "id"],
},
),
migrations.CreateModel(
name="RemoteSensingSubdivisionOptionBlock",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("cluster_label", models.PositiveIntegerField(db_index=True)),
("sub_block_code", models.CharField(db_index=True, max_length=64)),
("chunk_size_sqm", models.PositiveIntegerField(default=900)),
("centroid_lat", models.DecimalField(db_index=True, decimal_places=6, max_digits=9)),
("centroid_lon", models.DecimalField(db_index=True, decimal_places=6, max_digits=9)),
("geometry", models.JSONField(blank=True, default=dict)),
("cell_count", models.PositiveIntegerField(default=0)),
("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)),
("option", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="cluster_blocks", to="location_data.remotesensingsubdivisionoption")),
],
options={
"verbose_name": "remote sensing subdivision option block",
"verbose_name_plural": "remote sensing subdivision option blocks",
"ordering": ["option", "cluster_label", "id"],
},
),
migrations.CreateModel(
name="RemoteSensingSubdivisionOptionAssignment",
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="subdivision_option_assignments", to="location_data.analysisgridcell")),
("option", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="assignments", to="location_data.remotesensingsubdivisionoption")),
],
options={
"verbose_name": "remote sensing subdivision option assignment",
"verbose_name_plural": "remote sensing subdivision option assignments",
"ordering": ["option", "cluster_label", "cell__cell_code"],
},
),
migrations.AddConstraint(
model_name="remotesensingsubdivisionoption",
constraint=models.UniqueConstraint(fields=("result", "requested_k"), name="rs_subdiv_option_unique_result_requested_k"),
),
migrations.AddIndex(
model_name="remotesensingsubdivisionoption",
index=models.Index(fields=["result", "is_active"], name="rs_subdiv_option_active_idx"),
),
migrations.AddConstraint(
model_name="remotesensingsubdivisionoptionblock",
constraint=models.UniqueConstraint(fields=("option", "cluster_label"), name="rs_subdiv_option_block_unique_option_label"),
),
migrations.AddConstraint(
model_name="remotesensingsubdivisionoptionassignment",
constraint=models.UniqueConstraint(fields=("option", "cell"), name="rs_subdiv_option_assign_unique_option_cell"),
),
migrations.AddIndex(
model_name="remotesensingsubdivisionoptionassignment",
index=models.Index(fields=["option", "cluster_label"], name="rs_subopt_assign_lbl_idx"),
),
]