using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AmtScanner.Api.Migrations
{
///
public partial class AddWindowsCredentialsAndRemoteAccessTokens : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "WindowsCredentials",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Username = table.Column(type: "varchar(200)", maxLength: 200, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Password = table.Column(type: "varchar(500)", maxLength: 500, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Domain = table.Column(type: "varchar(200)", maxLength: 200, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsDefault = table.Column(type: "tinyint(1)", nullable: false),
Note = table.Column(type: "varchar(500)", maxLength: 500, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WindowsCredentials", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RemoteAccessTokens",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Token = table.Column(type: "varchar(64)", maxLength: 64, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceId = table.Column(type: "bigint", nullable: false),
WindowsCredentialId = table.Column(type: "bigint", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
ExpiresAt = table.Column(type: "datetime(6)", nullable: false),
IsUsed = table.Column(type: "tinyint(1)", nullable: false),
UsedAt = table.Column(type: "datetime(6)", nullable: true),
MaxUseCount = table.Column(type: "int", nullable: false),
UseCount = table.Column(type: "int", nullable: false),
Note = table.Column(type: "varchar(500)", maxLength: 500, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_RemoteAccessTokens", x => x.Id);
table.ForeignKey(
name: "FK_RemoteAccessTokens_AmtDevices_DeviceId",
column: x => x.DeviceId,
principalTable: "AmtDevices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RemoteAccessTokens_WindowsCredentials_WindowsCredentialId",
column: x => x.WindowsCredentialId,
principalTable: "WindowsCredentials",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RemoteAccessTokens_DeviceId",
table: "RemoteAccessTokens",
column: "DeviceId");
migrationBuilder.CreateIndex(
name: "IX_RemoteAccessTokens_Token",
table: "RemoteAccessTokens",
column: "Token",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RemoteAccessTokens_WindowsCredentialId",
table: "RemoteAccessTokens",
column: "WindowsCredentialId");
migrationBuilder.CreateIndex(
name: "IX_WindowsCredentials_Name",
table: "WindowsCredentials",
column: "Name");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RemoteAccessTokens");
migrationBuilder.DropTable(
name: "WindowsCredentials");
}
}
}