106 lines
4.4 KiB
C#
106 lines
4.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LANCommander.Server.Data.MySQL.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: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
CreatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
CreatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
UpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
|
|
},
|
|
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);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LibraryGame",
|
|
columns: table => new
|
|
{
|
|
GameId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
LibraryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
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);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
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");
|
|
}
|
|
}
|
|
}
|