UPDATE
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("farm_hub", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="FarmAlert",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("uuid", models.UUIDField(default=uuid.uuid4, editable=False, unique=True, db_index=True)),
|
||||
("farm", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="farm_alerts", to="farm_hub.farmhub")),
|
||||
("title", models.CharField(max_length=255)),
|
||||
("description", models.TextField(blank=True, default="")),
|
||||
("color", models.CharField(default="info", max_length=32)),
|
||||
("avatar_icon", models.CharField(blank=True, default="", max_length=64)),
|
||||
("avatar_color", models.CharField(blank=True, default="", max_length=32)),
|
||||
("is_active", models.BooleanField(default=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={"db_table": "farm_alerts", "ordering": ["-created_at"]},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="AnomalyDetection",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("uuid", models.UUIDField(default=uuid.uuid4, editable=False, unique=True, db_index=True)),
|
||||
("farm", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="anomalies", to="farm_hub.farmhub")),
|
||||
("sensor", models.CharField(max_length=255)),
|
||||
("value", models.CharField(max_length=64)),
|
||||
("expected", models.CharField(max_length=64)),
|
||||
("deviation", models.CharField(max_length=64)),
|
||||
("severity", models.CharField(default="warning", max_length=32)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={"db_table": "farm_anomaly_detections", "ordering": ["-created_at"]},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Recommendation",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("uuid", models.UUIDField(default=uuid.uuid4, editable=False, unique=True, db_index=True)),
|
||||
("farm", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="recommendations", to="farm_hub.farmhub")),
|
||||
("title", models.CharField(max_length=255)),
|
||||
("subtitle", models.TextField(blank=True, default="")),
|
||||
("avatar_icon", models.CharField(blank=True, default="", max_length=64)),
|
||||
("avatar_color", models.CharField(blank=True, default="", max_length=32)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={"db_table": "farm_recommendations", "ordering": ["-created_at"]},
|
||||
),
|
||||
]
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1.15 on 2026-04-25 21:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('farm_alerts', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='anomalydetection',
|
||||
name='severity',
|
||||
field=models.CharField(choices=[('info', 'Info'), ('warning', 'Warning'), ('error', 'Error'), ('success', 'Success')], default='warning', max_length=32),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='farmalert',
|
||||
name='color',
|
||||
field=models.CharField(choices=[('info', 'Info'), ('warning', 'Warning'), ('error', 'Error'), ('success', 'Success')], default='info', max_length=32),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,43 @@
|
||||
# Generated by Django 5.1.15 on 2026-04-28 23:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("farm_alerts", "0002_alter_anomalydetection_severity_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="external_alert_id",
|
||||
field=models.CharField(blank=True, db_index=True, default="", max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="occurred_at",
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="payload",
|
||||
field=models.JSONField(blank=True, default=dict),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="raw_alert",
|
||||
field=models.JSONField(blank=True, default=dict),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="source_metric_type",
|
||||
field=models.CharField(blank=True, default="", max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="farmalert",
|
||||
name="suggested_action",
|
||||
field=models.TextField(blank=True, default=""),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("farm_hub", "0001_initial"),
|
||||
("farm_alerts", "0003_farmalert_tracker_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="FarmAlertTrackerSnapshot",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("service_id", models.CharField(default="farm_alerts", max_length=64)),
|
||||
("tracker", models.JSONField(blank=True, default=dict)),
|
||||
("headline", models.CharField(blank=True, default="", max_length=255)),
|
||||
("overview", models.TextField(blank=True, default="")),
|
||||
(
|
||||
"status_level",
|
||||
models.CharField(
|
||||
choices=[("info", "Info"), ("warning", "Warning"), ("error", "Error"), ("success", "Success")],
|
||||
default="info",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
("raw_llm_response", models.TextField(blank=True, default="")),
|
||||
("structured_context", models.JSONField(blank=True, default=dict)),
|
||||
("last_ai_synced_at", models.DateTimeField(blank=True, null=True)),
|
||||
("last_source_update_at", models.DateTimeField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"farm",
|
||||
models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="alert_tracker_snapshot",
|
||||
to="farm_hub.farmhub",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"db_table": "farm_alert_tracker_snapshots",
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user