using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LANCommander.Migrations { /// public partial class AddLibraries : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { 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), 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_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(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_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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "LibraryGame"); migrationBuilder.DropTable( name: "Libraries"); } } }