Files
WMS/HHWMS.Web/Migrations/20260531025057_device_data_tables.cs
T

154 lines
10 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HHWMS.Web.Migrations
{
public partial class device_data_tables : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DeviceAlarmRecord",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DeviceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "设备唯一标识")
.Annotation("MySql:CharSet", "utf8mb4"),
AlarmCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "告警代码")
.Annotation("MySql:CharSet", "utf8mb4"),
AlarmMessage = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true, comment: "告警内容")
.Annotation("MySql:CharSet", "utf8mb4"),
StartTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "告警开始时间"),
EndTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "告警恢复时间"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否仍在告警"),
LastSeenTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "最后出现时间"),
RepeatCount = table.Column<int>(type: "int", nullable: false, comment: "重复出现次数"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceAlarmRecord", x => x.ID);
},
comment: "设备告警记录")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceCurrentState",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DeviceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "设备唯一标识")
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "设备显示名称")
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceType = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true, comment: "设备类型")
.Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true, comment: "当前状态")
.Annotation("MySql:CharSet", "utf8mb4"),
LastPayloadTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "最后设备数据时间"),
LastUpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "最后状态更新时间"),
AlarmSummary = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true, comment: "当前告警摘要")
.Annotation("MySql:CharSet", "utf8mb4"),
RealtimeJson = table.Column<string>(type: "longtext", nullable: true, comment: "清洗后的实时数据")
.Annotation("MySql:CharSet", "utf8mb4"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceCurrentState", x => x.ID);
},
comment: "设备当前状态")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceMetricTrendPoint",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DeviceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "设备唯一标识")
.Annotation("MySql:CharSet", "utf8mb4"),
MetricName = table.Column<string>(type: "varchar(60)", maxLength: 60, nullable: false, comment: "指标名称")
.Annotation("MySql:CharSet", "utf8mb4"),
BucketTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "聚合时间桶"),
AvgValue = table.Column<decimal>(type: "decimal(18,4)", nullable: false, comment: "平均值"),
MaxValue = table.Column<decimal>(type: "decimal(18,4)", nullable: false, comment: "最大值"),
MinValue = table.Column<decimal>(type: "decimal(18,4)", nullable: false, comment: "最小值"),
SampleCount = table.Column<int>(type: "int", nullable: false, comment: "样本数"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceMetricTrendPoint", x => x.ID);
},
comment: "设备指标趋势聚合点")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceProductionDaily",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DeviceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "设备唯一标识")
.Annotation("MySql:CharSet", "utf8mb4"),
ProductionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "生产日期"),
StartCounter = table.Column<int>(type: "int", nullable: false, comment: "当日开始累计值"),
EndCounter = table.Column<int>(type: "int", nullable: false, comment: "当日结束累计值"),
ProduceCount = table.Column<int>(type: "int", nullable: false, comment: "当日产量"),
RuntimeMinutes = table.Column<int>(type: "int", nullable: false, comment: "运行分钟数"),
CuttimeMinutes = table.Column<int>(type: "int", nullable: false, comment: "加工分钟数"),
AlarmMinutes = table.Column<int>(type: "int", nullable: false, comment: "报警分钟数"),
OfflineMinutes = table.Column<int>(type: "int", nullable: false, comment: "离线分钟数"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceProductionDaily", x => x.ID);
},
comment: "设备日产能汇总")
.Annotation("MySql:CharSet", "utf8mb4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceAlarmRecord");
migrationBuilder.DropTable(
name: "DeviceCurrentState");
migrationBuilder.DropTable(
name: "DeviceMetricTrendPoint");
migrationBuilder.DropTable(
name: "DeviceProductionDaily");
}
}
}