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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DriverName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), FileName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), AssembleName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), AuthorizesNum = table.Column(type: "int", nullable: false), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), GatewayName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClientId = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MqttIp = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MqttPort = table.Column(type: "int", nullable: false), MqttUName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MqttUPwd = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IoTPlatformType = table.Column(type: "int", nullable: false), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DeviceName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Index = table.Column(type: "int unsigned", nullable: false), Description = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DriverId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), AutoStart = table.Column(type: "tinyint(1)", nullable: false), CgUpload = table.Column(type: "tinyint(1)", nullable: false), EnforcePeriod = table.Column(type: "int unsigned", nullable: false), CmdPeriod = table.Column(type: "int unsigned", nullable: false), DeviceTypeEnum = table.Column(type: "int", nullable: false), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ParentId = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DeviceConfigName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DataSide = table.Column(type: "int", nullable: false), Description = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Value = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), EnumInfo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DeviceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Method = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DeviceAddress = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DataType = table.Column(type: "int", nullable: false), Expressions = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ProtectType = table.Column(type: "int", nullable: false), Index = table.Column(type: "int unsigned", nullable: false), DeviceId = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), RpcSide = table.Column(type: "int", nullable: false), StartTime = table.Column(type: "datetime(6)", nullable: false), DeviceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), Method = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Params = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), EndTime = table.Column(type: "datetime(6)", nullable: false), IsSuccess = table.Column(type: "tinyint(1)", nullable: false), Description = table.Column(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"); } } }