using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace EntityFrameworkCore.Data.Migrations { /// public partial class AddRelationshipConstraints : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "TeamId", table: "Coaches"); migrationBuilder.AlterColumn( name: "LeagueId", table: "Teams", type: "INTEGER", nullable: true, oldClrType: typeof(int), oldType: "INTEGER"); migrationBuilder.AddColumn( name: "AwayTeamScore", table: "Matches", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "HomeTeamScore", table: "Matches", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.InsertData( table: "Coaches", columns: new[] { "Id", "CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "Name" }, values: new object[,] { { 1, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Christian Southgate" }, { 2, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Rob Mann" }, { 3, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Jon Curtis" }, { 4, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Andy Taylor" }, { 5, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Steve Johnson" }, { 6, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Dan Cook" }, { 7, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Ken Jarvis" }, { 8, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Kenny Suzuki" }, { 9, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Gordon Hall" }, { 10, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "John O Dowd" }, { 11, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Julian Widdows" }, { 12, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Andy Williams" }, { 13, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Trevor Williams" }, { 14, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Blake Deathray" }, { 15, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Rock Housebrick" } }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 1, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 1, 2 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 2, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 2, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 3, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 3, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 4, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 4, 3 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 5, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 5, 2 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 6, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 6, 2 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 7, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 7, 3 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 8, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 8, 3 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 9, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 9, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 10, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 10, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 11, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 11, 4 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 12, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 12, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 13, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 13, 1 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 14, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 14, 4 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 15, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 15, 1 }); migrationBuilder.CreateIndex( name: "IX_Teams_CoachId", table: "Teams", column: "CoachId", unique: true); migrationBuilder.CreateIndex( name: "IX_Teams_LeagueId", table: "Teams", column: "LeagueId"); migrationBuilder.CreateIndex( name: "IX_Teams_Name", table: "Teams", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_Matches_AwayTeamId", table: "Matches", column: "AwayTeamId"); migrationBuilder.CreateIndex( name: "IX_Matches_HomeTeamId", table: "Matches", column: "HomeTeamId"); migrationBuilder.AddForeignKey( name: "FK_Matches_Teams_AwayTeamId", table: "Matches", column: "AwayTeamId", principalTable: "Teams", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Matches_Teams_HomeTeamId", table: "Matches", column: "HomeTeamId", principalTable: "Teams", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Teams_Coaches_CoachId", table: "Teams", column: "CoachId", principalTable: "Coaches", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Teams_Leagues_LeagueId", table: "Teams", column: "LeagueId", principalTable: "Leagues", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Matches_Teams_AwayTeamId", table: "Matches"); migrationBuilder.DropForeignKey( name: "FK_Matches_Teams_HomeTeamId", table: "Matches"); migrationBuilder.DropForeignKey( name: "FK_Teams_Coaches_CoachId", table: "Teams"); migrationBuilder.DropForeignKey( name: "FK_Teams_Leagues_LeagueId", table: "Teams"); migrationBuilder.DropIndex( name: "IX_Teams_CoachId", table: "Teams"); migrationBuilder.DropIndex( name: "IX_Teams_LeagueId", table: "Teams"); migrationBuilder.DropIndex( name: "IX_Teams_Name", table: "Teams"); migrationBuilder.DropIndex( name: "IX_Matches_AwayTeamId", table: "Matches"); migrationBuilder.DropIndex( name: "IX_Matches_HomeTeamId", table: "Matches"); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 1); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 2); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 3); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 4); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 5); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 6); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 7); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 8); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 9); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 10); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 11); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 12); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 13); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 14); migrationBuilder.DeleteData( table: "Coaches", keyColumn: "Id", keyValue: 15); migrationBuilder.DropColumn( name: "AwayTeamScore", table: "Matches"); migrationBuilder.DropColumn( name: "HomeTeamScore", table: "Matches"); migrationBuilder.AlterColumn( name: "LeagueId", table: "Teams", type: "INTEGER", nullable: false, defaultValue: 0, oldClrType: typeof(int), oldType: "INTEGER", oldNullable: true); migrationBuilder.AddColumn( name: "TeamId", table: "Coaches", type: "INTEGER", nullable: true); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 1, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 2, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 3, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 4, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 5, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 6, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 7, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 8, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 9, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 10, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 11, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 12, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 13, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 14, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); migrationBuilder.UpdateData( table: "Teams", keyColumn: "Id", keyValue: 15, columns: new[] { "CoachId", "LeagueId" }, values: new object[] { 0, 0 }); } } }