using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
///
public partial class AddEngineMetadata : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "EngineId",
table: "Games",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "Engines",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
Name = table.Column(type: "TEXT", nullable: false),
CreatedOn = table.Column(type: "TEXT", nullable: false),
CreatedById = table.Column(type: "TEXT", nullable: true),
UpdatedOn = table.Column(type: "TEXT", nullable: false),
UpdatedById = table.Column(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);
}
///
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");
}
}
}