iotgateway/IoTGateway.DataAccess/Migrations/20221107035318_CmdPeriod.cs

247 lines
13 KiB
C#
Raw Permalink Normal View History

2022-11-07 04:52:13 +00:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTGateway.DataAccess.Migrations
{
public partial class CmdPeriod : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Drivers",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DriverName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
FileName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
AssembleName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
AuthorizesNum = table.Column<int>(type: "int", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Drivers", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "SystemConfig",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
GatewayName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClientId = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MqttIp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MqttPort = table.Column<int>(type: "int", nullable: false),
MqttUName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MqttUPwd = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IoTPlatformType = table.Column<int>(type: "int", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_SystemConfig", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Devices",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeviceName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Index = table.Column<uint>(type: "int unsigned", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DriverId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
AutoStart = table.Column<bool>(type: "tinyint(1)", nullable: false),
CgUpload = table.Column<bool>(type: "tinyint(1)", nullable: false),
EnforcePeriod = table.Column<uint>(type: "int unsigned", nullable: false),
CmdPeriod = table.Column<uint>(type: "int unsigned", nullable: false),
DeviceTypeEnum = table.Column<int>(type: "int", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
CreateBy = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdateBy = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_Devices", x => x.ID);
table.ForeignKey(
name: "FK_Devices_Devices_ParentId",
column: x => x.ParentId,
principalTable: "Devices",
principalColumn: "ID");
table.ForeignKey(
name: "FK_Devices_Drivers_DriverId",
column: x => x.DriverId,
principalTable: "Drivers",
principalColumn: "ID");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceConfigs",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeviceConfigName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DataSide = table.Column<int>(type: "int", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Value = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EnumInfo = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceConfigs", x => x.ID);
table.ForeignKey(
name: "FK_DeviceConfigs_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "ID");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceVariables",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Method = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceAddress = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DataType = table.Column<int>(type: "int", nullable: false),
Expressions = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ProtectType = table.Column<int>(type: "int", nullable: false),
Index = table.Column<uint>(type: "int unsigned", nullable: false),
DeviceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceVariables", x => x.ID);
table.ForeignKey(
name: "FK_DeviceVariables_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "ID");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RpcLogs",
columns: table => new
{
ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RpcSide = table.Column<int>(type: "int", nullable: false),
StartTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
DeviceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Method = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Params = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EndTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
IsSuccess = table.Column<bool>(type: "tinyint(1)", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_RpcLogs", x => x.ID);
table.ForeignKey(
name: "FK_RpcLogs_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "ID");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_DeviceConfigs_DeviceId",
table: "DeviceConfigs",
column: "DeviceId");
migrationBuilder.CreateIndex(
name: "IX_Devices_DriverId",
table: "Devices",
column: "DriverId");
migrationBuilder.CreateIndex(
name: "IX_Devices_ParentId",
table: "Devices",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_DeviceVariables_DeviceId",
table: "DeviceVariables",
column: "DeviceId");
migrationBuilder.CreateIndex(
name: "IX_RpcLogs_DeviceId",
table: "RpcLogs",
column: "DeviceId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceConfigs");
migrationBuilder.DropTable(
name: "DeviceVariables");
migrationBuilder.DropTable(
name: "RpcLogs");
migrationBuilder.DropTable(
name: "SystemConfig");
migrationBuilder.DropTable(
name: "Devices");
migrationBuilder.DropTable(
name: "Drivers");
}
}
}