using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AmtScanner.Api.Migrations
{
///
public partial class AddOsDeviceAndSystemUuid : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "SystemUuid",
table: "AmtDevices",
type: "varchar(50)",
maxLength: 50,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "OsDevices",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IpAddress = table.Column(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SystemUuid = table.Column(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Hostname = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
OsType = table.Column(type: "int", nullable: false),
OsVersion = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Architecture = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
LoggedInUser = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
LastBootTime = table.Column(type: "datetime(6)", nullable: true),
MacAddress = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsOnline = table.Column(type: "tinyint(1)", nullable: false),
LastOnlineAt = table.Column(type: "datetime(6)", nullable: true),
DiscoveredAt = table.Column(type: "datetime(6)", nullable: false),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: false),
Description = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
AmtDeviceId = table.Column(type: "bigint", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_OsDevices", x => x.Id);
table.ForeignKey(
name: "FK_OsDevices_AmtDevices_AmtDeviceId",
column: x => x.AmtDeviceId,
principalTable: "AmtDevices",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AmtDevices_SystemUuid",
table: "AmtDevices",
column: "SystemUuid");
migrationBuilder.CreateIndex(
name: "IX_OsDevices_AmtDeviceId",
table: "OsDevices",
column: "AmtDeviceId");
migrationBuilder.CreateIndex(
name: "IX_OsDevices_IpAddress",
table: "OsDevices",
column: "IpAddress",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_OsDevices_SystemUuid",
table: "OsDevices",
column: "SystemUuid");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OsDevices");
migrationBuilder.DropIndex(
name: "IX_AmtDevices_SystemUuid",
table: "AmtDevices");
migrationBuilder.DropColumn(
name: "SystemUuid",
table: "AmtDevices");
}
}
}