# Generated by Django 3.2.12 on 2024-03-26 08:17

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("enm", "0023_mpoint_interval"),
    ]

    operations = [
        migrations.RunSQL(
            sql=[
                (
                    """
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE public.enm_mplogx (
    "timex" timestamptz NOT NULL,
    "mpoint_id" text NOT NULL,
    "val_mrs" smallint,
    "val_int" bigint,
    "val_float" float,
    "val_bool" boolean,
    "val_str" text,
    CONSTRAINT enm_mplogx_pkey PRIMARY KEY (timex, mpoint_id)
);
SELECT create_hypertable('enm_mplogx', 'timex');
                """
                )
            ],
            reverse_sql=["DROP TABLE IF EXISTS public.enm_mplogx;"],
        ),
        migrations.CreateModel(
            name="MpLogx",
            fields=[
                ("timex", models.DateTimeField(primary_key=True, serialize=False, verbose_name="采集时间")),
                ("val_mrs", models.PositiveSmallIntegerField(blank=True, null=True, verbose_name="所监测设备运行状态值")),
                ("val_float", models.FloatField(blank=True, null=True, verbose_name="数值")),
                ("val_int", models.IntegerField(blank=True, null=True, verbose_name="数值")),
                ("val_bool", models.BooleanField(blank=True, null=True, verbose_name="数值")),
                ("val_str", models.CharField(blank=True, max_length=100, null=True, verbose_name="数值")),
            ],
            options={
                "db_table": "enm_mplogx",
                "managed": False,
            },
        ),
        migrations.AddField(
            model_name="mpoint",
            name="enabled",
            field=models.BooleanField(default=False, verbose_name="是否启用"),
        ),
        migrations.AddField(
            model_name="mpoint",
            name="val_type",
            field=models.CharField(default="float", help_text="float, int, str, bool", max_length=50, verbose_name="值类型"),
        ),
        migrations.AlterField(
            model_name="mpoint",
            name="cate",
            field=models.CharField(blank=True, max_length=50, null=True, verbose_name="分类"),
        ),
        migrations.AlterField(
            model_name="mpoint",
            name="unit",
            field=models.CharField(blank=True, max_length=50, null=True, verbose_name="单位"),
        ),
    ]
