From 656e062040b461f5467afb833617c3489d72ad75 Mon Sep 17 00:00:00 2001 From: fxxian Date: Mon, 25 Mar 2024 19:33:56 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20mosqpost=20=E6=B7=BB=E5=8A=A0=E7=B4=A2?= =?UTF-8?q?=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0029_auto_20240325_1933.py | 22 +++++++++++++++++++ apps/mosquito/models.py | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 apps/mosquito/migrations/0029_auto_20240325_1933.py diff --git a/apps/mosquito/migrations/0029_auto_20240325_1933.py b/apps/mosquito/migrations/0029_auto_20240325_1933.py new file mode 100644 index 0000000..63ef754 --- /dev/null +++ b/apps/mosquito/migrations/0029_auto_20240325_1933.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.4 on 2024-03-25 11:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mosquito', '0028_deviceinfo_count'), + ] + + operations = [ + migrations.AlterField( + model_name='mosqpost', + name='device_id', + field=models.CharField(db_index=True, max_length=100, verbose_name='设备ID'), + ), + migrations.AlterUniqueTogether( + name='mosqpost', + unique_together={('device_id', 'create_time')}, + ), + ] diff --git a/apps/mosquito/models.py b/apps/mosquito/models.py index 1eca454..4ed6850 100644 --- a/apps/mosquito/models.py +++ b/apps/mosquito/models.py @@ -3,7 +3,7 @@ from smart.models import SmartModule, SmartPush class MosqPost(models.Model): - device_id = models.CharField(max_length=100, verbose_name='设备ID') + device_id = models.CharField(db_index=True, max_length=100, verbose_name='设备ID') count = models.PositiveIntegerField(verbose_name="灭蚊数量") load = models.CharField(max_length=100, blank=True, null=True, verbose_name='负载电压电流功率') storage_battery = models.CharField(max_length=100, blank=True, null=True, verbose_name='电池电压电流功率') @@ -14,6 +14,9 @@ class MosqPost(models.Model): update_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='更新时间') class Meta: + unique_together = ( + ('device_id', 'create_time'), + ) verbose_name = '灭蚊灯数据' verbose_name_plural = verbose_name