using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LANCommander.Launcher.Data.Migrations { /// public partial class AddUserLibraries : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserName = table.Column(type: "TEXT", nullable: true), Alias = table.Column(type: "TEXT", nullable: true), AvatarId = table.Column(type: "TEXT", nullable: true), CreatedOn = table.Column(type: "TEXT", nullable: false), UpdatedOn = table.Column(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(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), CreatedOn = table.Column(type: "TEXT", nullable: false), UpdatedOn = table.Column(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(type: "TEXT", nullable: false), LibraryId = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "LibraryGame"); migrationBuilder.DropTable( name: "Libraries"); migrationBuilder.DropTable( name: "Users"); } } }