109 lines
4.2 KiB
C#
109 lines
4.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LANCommander.Launcher.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddUserLibraries : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
UserName = table.Column<string>(type: "TEXT", nullable: true),
|
|
Alias = table.Column<string>(type: "TEXT", nullable: true),
|
|
AvatarId = table.Column<Guid>(type: "TEXT", nullable: true),
|
|
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Media_AvatarId",
|
|
column: x => x.AvatarId,
|
|
principalTable: "Media",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
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),
|
|
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Libraries", x => x.Id);
|
|
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_UserId",
|
|
table: "Libraries",
|
|
column: "UserId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LibraryGame_LibraryId",
|
|
table: "LibraryGame",
|
|
column: "LibraryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_AvatarId",
|
|
table: "Users",
|
|
column: "AvatarId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "LibraryGame");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Libraries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|