74 lines
3.1 KiB
C#
74 lines
3.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AmtScanner.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddDeviceReservation : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DeviceReservations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
DeviceId = table.Column<long>(type: "bigint", nullable: false),
|
|
UserId = table.Column<int>(type: "int", nullable: false),
|
|
StartTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
EndTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
AccessToken = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Note = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DeviceReservations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeviceReservations_AmtDevices_DeviceId",
|
|
column: x => x.DeviceId,
|
|
principalTable: "AmtDevices",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DeviceReservations_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeviceReservations_DeviceId",
|
|
table: "DeviceReservations",
|
|
column: "DeviceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeviceReservations_DeviceId_Status_EndTime",
|
|
table: "DeviceReservations",
|
|
columns: new[] { "DeviceId", "Status", "EndTime" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeviceReservations_UserId",
|
|
table: "DeviceReservations",
|
|
column: "UserId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DeviceReservations");
|
|
}
|
|
}
|
|
}
|