89 lines
3.1 KiB
C#
89 lines
3.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LANCommander.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddEngineMetadata : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "EngineId",
|
|
table: "Games",
|
|
type: "TEXT",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Engines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
CreatedById = table.Column<Guid>(type: "TEXT", nullable: true),
|
|
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
UpdatedById = table.Column<Guid>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Engines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Engines_AspNetUsers_CreatedById",
|
|
column: x => x.CreatedById,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Engines_AspNetUsers_UpdatedById",
|
|
column: x => x.UpdatedById,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Games_EngineId",
|
|
table: "Games",
|
|
column: "EngineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Engines_CreatedById",
|
|
table: "Engines",
|
|
column: "CreatedById");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Engines_UpdatedById",
|
|
table: "Engines",
|
|
column: "UpdatedById");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Games_Engines_EngineId",
|
|
table: "Games",
|
|
column: "EngineId",
|
|
principalTable: "Engines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Games_Engines_EngineId",
|
|
table: "Games");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Engines");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Games_EngineId",
|
|
table: "Games");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "EngineId",
|
|
table: "Games");
|
|
}
|
|
}
|
|
}
|