# Generated by Django 3.2.12 on 2024-01-19 02:53

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
    dependencies = [
        ("enp", "0001_initial"),
    ]

    operations = [
        migrations.RunSQL(
            sql=[
                (
                    """
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE public.enp_envdata (
    "timex" timestamptz NOT NULL,
    "equipment_id" text NOT NULL,
    "running_state" INT DEFAULT 10,
    "dust_rtd" float,
    "dust_zs" float,
    "temperature" float,
    "pressure" float,
    "speed" float,
    "humidity" float,
    "flux" float,
    "pm25" float,
    "pm10" float,
    "tsp" float,
    "wind_direction" int,
    "wind_speed" float,
    "so2_rtd" float,
    "so2_zs" float,
    "nox_rtd" float,
    "nox_zs" float,
    "o2" float,
    "ammonia_e" float,
    CONSTRAINT enp_envdata_pkey PRIMARY KEY (timex, equipment_id)
);
SELECT create_hypertable('enp_envdata', 'timex');
                """
                )
            ],
            reverse_sql=["DROP TABLE IF EXISTS public.enp_envdata;"],
        ),
        migrations.CreateModel(
            name="EnvData",
            fields=[
                ("time", models.DateTimeField(primary_key=True, serialize=False, verbose_name="采集时间")),
                ("running_state", models.PositiveSmallIntegerField(default=10, verbose_name="运行状态")),
                ("dust_rtd", models.FloatField(blank=True, null=True, verbose_name="颗粒物实测(mg/m3)")),
                ("dust_zs", models.FloatField(blank=True, null=True, verbose_name="颗粒物折算(mg/m3)")),
                ("temperature", models.FloatField(blank=True, null=True, verbose_name="温度(℃)")),
                ("pressure", models.FloatField(blank=True, null=True, verbose_name="压力(kPa)")),
                ("speed", models.FloatField(blank=True, null=True, verbose_name="流速(m/s)")),
                ("humidity", models.FloatField(blank=True, null=True, verbose_name="湿度(%)")),
                ("flux", models.FloatField(blank=True, null=True, verbose_name="流量(m3/h)")),
                ("pm25", models.FloatField(blank=True, null=True, verbose_name="PM2.5(ug/m3)")),
                ("pm10", models.FloatField(blank=True, null=True, verbose_name="PM10(ug/m3)")),
                ("tsp", models.FloatField(blank=True, null=True, verbose_name="TSP(ug/m3)")),
                ("wind_direction", models.PositiveSmallIntegerField(blank=True, null=True, verbose_name="风向")),
                ("wind_speed", models.FloatField(blank=True, null=True, verbose_name="风速(m/s)")),
                ("so2_rtd", models.FloatField(blank=True, null=True, verbose_name="二氧化硫实测(mg/m3)")),
                ("so2_zs", models.FloatField(blank=True, null=True, verbose_name="二氧化硫折算(mg/m3)")),
                ("nox_rtd", models.FloatField(blank=True, null=True, verbose_name="氮氧化物实测(mg/m3)")),
                ("nox_zs", models.FloatField(blank=True, null=True, verbose_name="氮氧化物折算(mg/m3)")),
                ("o2", models.FloatField(blank=True, null=True, verbose_name="含氧量(%)")),
            ],
            options={
                "db_table": "enp_envdata",
                "managed": False,
            },
        ),
        migrations.AddField(
            model_name="drainequip",
            name="dust_alarm",
            field=models.DecimalField(blank=True, decimal_places=4, max_digits=10, null=True, verbose_name="颗粒物报警值"),
        ),
        migrations.AlterField(
            model_name="drainequip",
            name="drain",
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="drainequip_drain", to="enp.drain", verbose_name="排口"),
        ),
        migrations.AlterField(
            model_name="drainequip",
            name="equipment",
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="drainequip_equipment", to="em.equipment", verbose_name="关联设备"),
        ),
    ]
