using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace Database.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "dbo"); migrationBuilder.CreateTable( name: "Alliances", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Server = table.Column(type: "int", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Abbreviation = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Alliances", x => x.Id); }); migrationBuilder.CreateTable( name: "Ranks", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(2)", maxLength: 2, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Ranks", x => x.Id); }); migrationBuilder.CreateTable( name: "Roles", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), AllianceId = table.Column(type: "uniqueidentifier", nullable: false), PlayerName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column(type: "bit", nullable: false), PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), TwoFactorEnabled = table.Column(type: "bit", nullable: false), LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), LockoutEnabled = table.Column(type: "bit", nullable: false), AccessFailedCount = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); table.ForeignKey( name: "FK_Users_Alliances_AllianceId", column: x => x.AllianceId, principalSchema: "dbo", principalTable: "Alliances", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Players", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), PlayerName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), RankId = table.Column(type: "uniqueidentifier", nullable: false), AllianceId = table.Column(type: "uniqueidentifier", nullable: false), Level = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Players", x => x.Id); table.ForeignKey( name: "FK_Players_Alliances_AllianceId", column: x => x.AllianceId, principalSchema: "dbo", principalTable: "Alliances", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Players_Ranks_RankId", column: x => x.RankId, principalSchema: "dbo", principalTable: "Ranks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "RoleClaims", schema: "dbo", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RoleId = table.Column(type: "uniqueidentifier", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_RoleClaims", x => x.Id); table.ForeignKey( name: "FK_RoleClaims_Roles_RoleId", column: x => x.RoleId, principalSchema: "dbo", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserClaims", schema: "dbo", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), UserId = table.Column(type: "uniqueidentifier", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserClaims", x => x.Id); table.ForeignKey( name: "FK_UserClaims_Users_UserId", column: x => x.UserId, principalSchema: "dbo", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserLogins", schema: "dbo", columns: table => new { LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), UserId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_UserLogins_Users_UserId", column: x => x.UserId, principalSchema: "dbo", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserRoles", schema: "dbo", columns: table => new { UserId = table.Column(type: "uniqueidentifier", nullable: false), RoleId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_UserRoles_Roles_RoleId", column: x => x.RoleId, principalSchema: "dbo", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UserRoles_Users_UserId", column: x => x.UserId, principalSchema: "dbo", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserTokens", schema: "dbo", columns: table => new { UserId = table.Column(type: "uniqueidentifier", nullable: false), LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(450)", nullable: false), Value = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_UserTokens_Users_UserId", column: x => x.UserId, principalSchema: "dbo", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Admonitions", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Reason = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), PlayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Admonitions", x => x.Id); table.ForeignKey( name: "FK_Admonitions_Players_PlayerId", column: x => x.PlayerId, principalSchema: "dbo", principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DesertStorms", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Registered = table.Column(type: "bit", nullable: false), Participated = table.Column(type: "bit", nullable: false), Year = table.Column(type: "int", nullable: false), CalendarWeek = table.Column(type: "int", nullable: false), PlayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DesertStorms", x => x.Id); table.ForeignKey( name: "FK_DesertStorms_Players_PlayerId", column: x => x.PlayerId, principalSchema: "dbo", principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MarshalGuards", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Participated = table.Column(type: "bit", nullable: false), Year = table.Column(type: "int", nullable: false), Month = table.Column(type: "int", nullable: false), Day = table.Column(type: "int", nullable: false), PlayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MarshalGuards", x => x.Id); table.ForeignKey( name: "FK_MarshalGuards_Players_PlayerId", column: x => x.PlayerId, principalSchema: "dbo", principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Notes", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), PlayerNote = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), PlayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Notes", x => x.Id); table.ForeignKey( name: "FK_Notes_Players_PlayerId", column: x => x.PlayerId, principalSchema: "dbo", principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "VsDuels", schema: "dbo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), WeeklyPoints = table.Column(type: "int", nullable: false), Year = table.Column(type: "int", nullable: false), CalendarWeek = table.Column(type: "int", nullable: false), PlayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_VsDuels", x => x.Id); table.ForeignKey( name: "FK_VsDuels_Players_PlayerId", column: x => x.PlayerId, principalSchema: "dbo", principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( schema: "dbo", table: "Ranks", columns: new[] { "Id", "Name" }, values: new object[,] { { new Guid("0fc2f68a-0a4d-4922-981e-c624e4c39024"), "R4" }, { new Guid("326edef0-5074-43a5-9db9-edc71221a0f7"), "R1" }, { new Guid("4970e1f5-f7f5-43e8-88cc-7f8fc4075418"), "R3" }, { new Guid("b1c10a1c-5cf3-4e22-9fc1-d9b165b85dd3"), "R5" }, { new Guid("d8d0c587-f269-45ff-b13e-4631298bf0af"), "R2" } }); migrationBuilder.InsertData( schema: "dbo", table: "Roles", columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, values: new object[,] { { new Guid("207bb0a3-ad50-49bb-bc41-b266fce66529"), null, "ReadOnly", "READONLY" }, { new Guid("47de05ba-ff1e-46b6-9995-269084006c24"), null, "Administrator", "ADMINISTRATOR" }, { new Guid("5cc27946-5601-4a25-b9a9-75b8a11c0cf4"), null, "User", "USER" }, { new Guid("d8b9f882-95f0-4ba0-80ed-9c22c27ac88a"), null, "SystemAdministrator", "SYSTEMADMINISTRATOR" } }); migrationBuilder.CreateIndex( name: "IX_Admonitions_PlayerId", schema: "dbo", table: "Admonitions", column: "PlayerId"); migrationBuilder.CreateIndex( name: "IX_DesertStorms_PlayerId", schema: "dbo", table: "DesertStorms", column: "PlayerId"); migrationBuilder.CreateIndex( name: "IX_MarshalGuards_PlayerId", schema: "dbo", table: "MarshalGuards", column: "PlayerId"); migrationBuilder.CreateIndex( name: "IX_Notes_PlayerId", schema: "dbo", table: "Notes", column: "PlayerId"); migrationBuilder.CreateIndex( name: "IX_Players_AllianceId", schema: "dbo", table: "Players", column: "AllianceId"); migrationBuilder.CreateIndex( name: "IX_Players_RankId", schema: "dbo", table: "Players", column: "RankId"); migrationBuilder.CreateIndex( name: "IX_RoleClaims_RoleId", schema: "dbo", table: "RoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", schema: "dbo", table: "Roles", column: "NormalizedName", unique: true, filter: "[NormalizedName] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_UserClaims_UserId", schema: "dbo", table: "UserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserLogins_UserId", schema: "dbo", table: "UserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", schema: "dbo", table: "UserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", schema: "dbo", table: "Users", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "IX_Users_AllianceId", schema: "dbo", table: "Users", column: "AllianceId"); migrationBuilder.CreateIndex( name: "UserNameIndex", schema: "dbo", table: "Users", column: "NormalizedUserName", unique: true, filter: "[NormalizedUserName] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_VsDuels_PlayerId", schema: "dbo", table: "VsDuels", column: "PlayerId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Admonitions", schema: "dbo"); migrationBuilder.DropTable( name: "DesertStorms", schema: "dbo"); migrationBuilder.DropTable( name: "MarshalGuards", schema: "dbo"); migrationBuilder.DropTable( name: "Notes", schema: "dbo"); migrationBuilder.DropTable( name: "RoleClaims", schema: "dbo"); migrationBuilder.DropTable( name: "UserClaims", schema: "dbo"); migrationBuilder.DropTable( name: "UserLogins", schema: "dbo"); migrationBuilder.DropTable( name: "UserRoles", schema: "dbo"); migrationBuilder.DropTable( name: "UserTokens", schema: "dbo"); migrationBuilder.DropTable( name: "VsDuels", schema: "dbo"); migrationBuilder.DropTable( name: "Roles", schema: "dbo"); migrationBuilder.DropTable( name: "Users", schema: "dbo"); migrationBuilder.DropTable( name: "Players", schema: "dbo"); migrationBuilder.DropTable( name: "Alliances", schema: "dbo"); migrationBuilder.DropTable( name: "Ranks", schema: "dbo"); } } }