using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace AmtScanner.Api.Migrations { /// public partial class AddHardwareInfo : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "HardwareInfos", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), DeviceId = table.Column(type: "bigint", nullable: false), LastUpdated = table.Column(type: "datetime(6)", nullable: false), SystemManufacturer = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SystemModel = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SystemSerialNumber = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ProcessorModel = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ProcessorCores = table.Column(type: "int", nullable: true), ProcessorThreads = table.Column(type: "int", nullable: true), ProcessorMaxClockSpeed = table.Column(type: "int", nullable: true), ProcessorCurrentClockSpeed = table.Column(type: "int", nullable: true), TotalMemoryBytes = table.Column(type: "bigint", nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HardwareInfos", x => x.Id); table.ForeignKey( name: "FK_HardwareInfos_AmtDevices_DeviceId", column: x => x.DeviceId, principalTable: "AmtDevices", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "MemoryModules", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), HardwareInfoId = table.Column(type: "bigint", nullable: false), SlotLocation = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CapacityBytes = table.Column(type: "bigint", nullable: true), SpeedMHz = table.Column(type: "int", nullable: true), MemoryType = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Manufacturer = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PartNumber = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SerialNumber = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_MemoryModules", x => x.Id); table.ForeignKey( name: "FK_MemoryModules_HardwareInfos_HardwareInfoId", column: x => x.HardwareInfoId, principalTable: "HardwareInfos", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "StorageDevices", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), HardwareInfoId = table.Column(type: "bigint", nullable: false), DeviceId = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Model = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CapacityBytes = table.Column(type: "bigint", nullable: true), InterfaceType = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_StorageDevices", x => x.Id); table.ForeignKey( name: "FK_StorageDevices_HardwareInfos_HardwareInfoId", column: x => x.HardwareInfoId, principalTable: "HardwareInfos", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_HardwareInfos_DeviceId", table: "HardwareInfos", column: "DeviceId"); migrationBuilder.CreateIndex( name: "IX_HardwareInfos_LastUpdated", table: "HardwareInfos", column: "LastUpdated"); migrationBuilder.CreateIndex( name: "IX_MemoryModules_HardwareInfoId", table: "MemoryModules", column: "HardwareInfoId"); migrationBuilder.CreateIndex( name: "IX_StorageDevices_HardwareInfoId", table: "StorageDevices", column: "HardwareInfoId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "MemoryModules"); migrationBuilder.DropTable( name: "StorageDevices"); migrationBuilder.DropTable( name: "HardwareInfos"); } } }