145 lines
7.0 KiB
C#
145 lines
7.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AmtScanner.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddHardwareInfo : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "HardwareInfos",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
DeviceId = table.Column<long>(type: "bigint", nullable: false),
|
|
LastUpdated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
SystemManufacturer = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SystemModel = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SystemSerialNumber = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProcessorModel = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProcessorCores = table.Column<int>(type: "int", nullable: true),
|
|
ProcessorThreads = table.Column<int>(type: "int", nullable: true),
|
|
ProcessorMaxClockSpeed = table.Column<int>(type: "int", nullable: true),
|
|
ProcessorCurrentClockSpeed = table.Column<int>(type: "int", nullable: true),
|
|
TotalMemoryBytes = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
HardwareInfoId = table.Column<long>(type: "bigint", nullable: false),
|
|
SlotLocation = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CapacityBytes = table.Column<long>(type: "bigint", nullable: true),
|
|
SpeedMHz = table.Column<int>(type: "int", nullable: true),
|
|
MemoryType = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Manufacturer = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PartNumber = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SerialNumber = table.Column<string>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
HardwareInfoId = table.Column<long>(type: "bigint", nullable: false),
|
|
DeviceId = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Model = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CapacityBytes = table.Column<long>(type: "bigint", nullable: true),
|
|
InterfaceType = table.Column<string>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "MemoryModules");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "StorageDevices");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "HardwareInfos");
|
|
}
|
|
}
|
|
}
|