using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LANCommander.Migrations { /// public partial class AddCollections : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Collections", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = 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_Collections", x => x.Id); table.ForeignKey( name: "FK_Collections_AspNetUsers_CreatedById", column: x => x.CreatedById, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_Collections_AspNetUsers_UpdatedById", column: x => x.UpdatedById, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateTable( name: "CollectionGame", columns: table => new { CollectionId = table.Column(type: "TEXT", nullable: false), GameId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CollectionGame", x => new { x.CollectionId, x.GameId }); table.ForeignKey( name: "FK_CollectionGame_Collections_CollectionId", column: x => x.CollectionId, principalTable: "Collections", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_CollectionGame_Games_GameId", column: x => x.GameId, principalTable: "Games", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "RoleCollection", columns: table => new { CollectionId = table.Column(type: "TEXT", nullable: false), RoleId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RoleCollection", x => new { x.CollectionId, x.RoleId }); table.ForeignKey( name: "FK_RoleCollection_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_RoleCollection_Collections_CollectionId", column: x => x.CollectionId, principalTable: "Collections", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_CollectionGame_GameId", table: "CollectionGame", column: "GameId"); migrationBuilder.CreateIndex( name: "IX_Collections_CreatedById", table: "Collections", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Collections_UpdatedById", table: "Collections", column: "UpdatedById"); migrationBuilder.CreateIndex( name: "IX_RoleCollection_RoleId", table: "RoleCollection", column: "RoleId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CollectionGame"); migrationBuilder.DropTable( name: "RoleCollection"); migrationBuilder.DropTable( name: "Collections"); } } }