using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Data.Migrations { /// public partial class ConfigurationRefactor : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_StudentTeam_Students_StudentsId", table: "StudentTeam"); migrationBuilder.DropForeignKey( name: "FK_StudentTeam_Teams_TeamsId", table: "StudentTeam"); migrationBuilder.DropForeignKey( name: "FK_Teams_Events_EventId", table: "Teams"); migrationBuilder.DropForeignKey( name: "FK_Teams_Students_CaptainId", table: "Teams"); migrationBuilder.DropPrimaryKey( name: "PK_StudentEventRanking", table: "StudentEventRanking"); migrationBuilder.DropIndex( name: "IX_Events_Name", table: "Events"); migrationBuilder.DropPrimaryKey( name: "PK_StudentTeam", table: "StudentTeam"); migrationBuilder.RenameTable( name: "StudentTeam", newName: "TeamStudents"); migrationBuilder.RenameIndex( name: "IX_StudentTeam_TeamsId", table: "TeamStudents", newName: "IX_TeamStudents_TeamsId"); migrationBuilder.AlterColumn( name: "OfficerRole", table: "Students", type: "TEXT", maxLength: 50, nullable: true, oldClrType: typeof(int), oldType: "INTEGER", oldNullable: true); migrationBuilder.AlterColumn( name: "EventFormat", table: "Events", type: "TEXT", maxLength: 50, nullable: false, oldClrType: typeof(int), oldType: "INTEGER"); migrationBuilder.AddPrimaryKey( name: "PK_StudentEventRanking", table: "StudentEventRanking", columns: new[] { "StudentId", "EventDefinitionId" }); migrationBuilder.AddPrimaryKey( name: "PK_TeamStudents", table: "TeamStudents", columns: new[] { "StudentsId", "TeamsId" }); migrationBuilder.CreateIndex( name: "IX_Teams_EventId_Identifier", table: "Teams", columns: new[] { "EventId", "Identifier" }); migrationBuilder.CreateIndex( name: "IX_Students_Email", table: "Students", column: "Email"); migrationBuilder.CreateIndex( name: "IX_Students_FirstName_LastName", table: "Students", columns: new[] { "FirstName", "LastName" }); migrationBuilder.CreateIndex( name: "IX_Students_Grade", table: "Students", column: "Grade"); migrationBuilder.CreateIndex( name: "IX_StudentEventRanking_EventDefinitionId", table: "StudentEventRanking", column: "EventDefinitionId"); migrationBuilder.CreateIndex( name: "IX_StudentEventRanking_Rank", table: "StudentEventRanking", column: "Rank"); migrationBuilder.CreateIndex( name: "IX_Events_EventFormat", table: "Events", column: "EventFormat"); migrationBuilder.CreateIndex( name: "IX_Events_Name", table: "Events", column: "Name", unique: true); migrationBuilder.AddForeignKey( name: "FK_Teams_Events_EventId", table: "Teams", column: "EventId", principalTable: "Events", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Teams_Students_CaptainId", table: "Teams", column: "CaptainId", principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_TeamStudents_Students_StudentsId", table: "TeamStudents", column: "StudentsId", principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TeamStudents_Teams_TeamsId", table: "TeamStudents", column: "TeamsId", principalTable: "Teams", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Teams_Events_EventId", table: "Teams"); migrationBuilder.DropForeignKey( name: "FK_Teams_Students_CaptainId", table: "Teams"); migrationBuilder.DropForeignKey( name: "FK_TeamStudents_Students_StudentsId", table: "TeamStudents"); migrationBuilder.DropForeignKey( name: "FK_TeamStudents_Teams_TeamsId", table: "TeamStudents"); migrationBuilder.DropIndex( name: "IX_Teams_EventId_Identifier", table: "Teams"); migrationBuilder.DropIndex( name: "IX_Students_Email", table: "Students"); migrationBuilder.DropIndex( name: "IX_Students_FirstName_LastName", table: "Students"); migrationBuilder.DropIndex( name: "IX_Students_Grade", table: "Students"); migrationBuilder.DropPrimaryKey( name: "PK_StudentEventRanking", table: "StudentEventRanking"); migrationBuilder.DropIndex( name: "IX_StudentEventRanking_EventDefinitionId", table: "StudentEventRanking"); migrationBuilder.DropIndex( name: "IX_StudentEventRanking_Rank", table: "StudentEventRanking"); migrationBuilder.DropIndex( name: "IX_Events_EventFormat", table: "Events"); migrationBuilder.DropIndex( name: "IX_Events_Name", table: "Events"); migrationBuilder.DropPrimaryKey( name: "PK_TeamStudents", table: "TeamStudents"); migrationBuilder.RenameTable( name: "TeamStudents", newName: "StudentTeam"); migrationBuilder.RenameIndex( name: "IX_TeamStudents_TeamsId", table: "StudentTeam", newName: "IX_StudentTeam_TeamsId"); migrationBuilder.AlterColumn( name: "OfficerRole", table: "Students", type: "INTEGER", nullable: true, oldClrType: typeof(string), oldType: "TEXT", oldMaxLength: 50, oldNullable: true); migrationBuilder.AlterColumn( name: "EventFormat", table: "Events", type: "INTEGER", nullable: false, oldClrType: typeof(string), oldType: "TEXT", oldMaxLength: 50); migrationBuilder.AddPrimaryKey( name: "PK_StudentEventRanking", table: "StudentEventRanking", columns: new[] { "EventDefinitionId", "StudentId" }); migrationBuilder.AddPrimaryKey( name: "PK_StudentTeam", table: "StudentTeam", columns: new[] { "StudentsId", "TeamsId" }); migrationBuilder.CreateIndex( name: "IX_Events_Name", table: "Events", column: "Name"); migrationBuilder.AddForeignKey( name: "FK_StudentTeam_Students_StudentsId", table: "StudentTeam", column: "StudentsId", principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_StudentTeam_Teams_TeamsId", table: "StudentTeam", column: "TeamsId", principalTable: "Teams", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Teams_Events_EventId", table: "Teams", column: "EventId", principalTable: "Events", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Teams_Students_CaptainId", table: "Teams", column: "CaptainId", principalTable: "Students", principalColumn: "Id"); } } }