105 lines
4 KiB
C#
105 lines
4 KiB
C#
|
|
using System;
|
|||
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|
|||
|
|
#nullable disable
|
|||
|
|
|
|||
|
|
namespace LANCommander.Migrations
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
public partial class AddLibraries : Migration
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
|
{
|
|||
|
|
migrationBuilder.CreateTable(
|
|||
|
|
name: "Libraries",
|
|||
|
|
columns: table => new
|
|||
|
|
{
|
|||
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|||
|
|
UserId = table.Column<Guid>(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_Libraries", x => x.Id);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_Libraries_Users_CreatedById",
|
|||
|
|
column: x => x.CreatedById,
|
|||
|
|
principalTable: "Users",
|
|||
|
|
principalColumn: "Id",
|
|||
|
|
onDelete: ReferentialAction.SetNull);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_Libraries_Users_UpdatedById",
|
|||
|
|
column: x => x.UpdatedById,
|
|||
|
|
principalTable: "Users",
|
|||
|
|
principalColumn: "Id",
|
|||
|
|
onDelete: ReferentialAction.SetNull);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_Libraries_Users_UserId",
|
|||
|
|
column: x => x.UserId,
|
|||
|
|
principalTable: "Users",
|
|||
|
|
principalColumn: "Id",
|
|||
|
|
onDelete: ReferentialAction.Cascade);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateTable(
|
|||
|
|
name: "LibraryGame",
|
|||
|
|
columns: table => new
|
|||
|
|
{
|
|||
|
|
GameId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|||
|
|
LibraryId = table.Column<Guid>(type: "TEXT", nullable: false)
|
|||
|
|
},
|
|||
|
|
constraints: table =>
|
|||
|
|
{
|
|||
|
|
table.PrimaryKey("PK_LibraryGame", x => new { x.GameId, x.LibraryId });
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_LibraryGame_Games_GameId",
|
|||
|
|
column: x => x.GameId,
|
|||
|
|
principalTable: "Games",
|
|||
|
|
principalColumn: "Id",
|
|||
|
|
onDelete: ReferentialAction.Cascade);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_LibraryGame_Libraries_LibraryId",
|
|||
|
|
column: x => x.LibraryId,
|
|||
|
|
principalTable: "Libraries",
|
|||
|
|
principalColumn: "Id",
|
|||
|
|
onDelete: ReferentialAction.Cascade);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_Libraries_CreatedById",
|
|||
|
|
table: "Libraries",
|
|||
|
|
column: "CreatedById");
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_Libraries_UpdatedById",
|
|||
|
|
table: "Libraries",
|
|||
|
|
column: "UpdatedById");
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_Libraries_UserId",
|
|||
|
|
table: "Libraries",
|
|||
|
|
column: "UserId",
|
|||
|
|
unique: true);
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_LibraryGame_LibraryId",
|
|||
|
|
table: "LibraryGame",
|
|||
|
|
column: "LibraryId");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
|
{
|
|||
|
|
migrationBuilder.DropTable(
|
|||
|
|
name: "LibraryGame");
|
|||
|
|
|
|||
|
|
migrationBuilder.DropTable(
|
|||
|
|
name: "Libraries");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|