From b56a19d8b8e3a13a37e0a93762f22a028bd0778f Mon Sep 17 00:00:00 2001 From: Kevin Matsubara Date: Mon, 7 Apr 2025 11:58:11 +0200 Subject: [PATCH] Recreate consolidation of migrations after fixes. --- ...737_AddRelationshipConstraints.Designer.cs | 490 ++++++++++++++++++ ...250407095737_AddRelationshipConstraints.cs | 472 +++++++++++++++++ ...eadBallZoneLeagueDbContextModelSnapshot.cs | 251 +++++++-- 3 files changed, 1175 insertions(+), 38 deletions(-) create mode 100644 EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs create mode 100644 EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.cs diff --git a/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs b/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs new file mode 100644 index 0000000..a7351a9 --- /dev/null +++ b/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs @@ -0,0 +1,490 @@ +// +using System; +using EntityFrameworkCore.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkCore.Data.Migrations +{ + [DbContext(typeof(DeadBallZoneLeagueDbContext))] + [Migration("20250407095737_AddRelationshipConstraints")] + partial class AddRelationshipConstraints + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedDate") + .HasColumnType("TEXT"); + + b.Property("ModifiedBy") + .HasColumnType("TEXT"); + + b.Property("ModifiedDate") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Coaches"); + + b.HasData( + new + { + Id = 1, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Christian Southgate" + }, + new + { + Id = 2, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Rob Mann" + }, + new + { + Id = 3, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Jon Curtis" + }, + new + { + Id = 4, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Andy Taylor" + }, + new + { + Id = 5, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Steve Johnson" + }, + new + { + Id = 6, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Dan Cook" + }, + new + { + Id = 7, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Ken Jarvis" + }, + new + { + Id = 8, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Kenny Suzuki" + }, + new + { + Id = 9, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Gordon Hall" + }, + new + { + Id = 10, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "John O Dowd" + }, + new + { + Id = 11, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Julian Widdows" + }, + new + { + Id = 12, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Andy Williams" + }, + new + { + Id = 13, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Trevor Williams" + }, + new + { + Id = 14, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Blake Deathray" + }, + new + { + Id = 15, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Rock Housebrick" + }); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.League", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedDate") + .HasColumnType("TEXT"); + + b.Property("ModifiedBy") + .HasColumnType("TEXT"); + + b.Property("ModifiedDate") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Leagues"); + + b.HasData( + new + { + Id = 1, + CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Local League" + }, + new + { + Id = 2, + CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "National League" + }, + new + { + Id = 3, + CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Geosphere" + }, + new + { + Id = 4, + CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Cyber war" + }); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AwayTeamId") + .HasColumnType("INTEGER"); + + b.Property("AwayTeamScore") + .HasColumnType("INTEGER"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedDate") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("HomeTeamId") + .HasColumnType("INTEGER"); + + b.Property("HomeTeamScore") + .HasColumnType("INTEGER"); + + b.Property("ModifiedBy") + .HasColumnType("TEXT"); + + b.Property("ModifiedDate") + .HasColumnType("TEXT"); + + b.Property("TicketPrice") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AwayTeamId"); + + b.HasIndex("HomeTeamId"); + + b.ToTable("Matches"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CoachId") + .HasColumnType("INTEGER"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedDate") + .HasColumnType("TEXT"); + + b.Property("LeagueId") + .HasColumnType("INTEGER"); + + b.Property("ModifiedBy") + .HasColumnType("TEXT"); + + b.Property("ModifiedDate") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CoachId") + .IsUnique(); + + b.HasIndex("LeagueId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Teams"); + + b.HasData( + new + { + Id = 1, + CoachId = 1, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 2, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Delhi" + }, + new + { + Id = 2, + CoachId = 2, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Voodoo" + }, + new + { + Id = 3, + CoachId = 3, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Penal X" + }, + new + { + Id = 4, + CoachId = 4, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 3, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Tokyo" + }, + new + { + Id = 5, + CoachId = 5, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 2, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Barcelona" + }, + new + { + Id = 6, + CoachId = 6, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 2, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Manchester" + }, + new + { + Id = 7, + CoachId = 7, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 3, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Bangkok" + }, + new + { + Id = 8, + CoachId = 8, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 3, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Neo Amsterdam" + }, + new + { + Id = 9, + CoachId = 9, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Killaklowns" + }, + new + { + Id = 10, + CoachId = 10, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Sol" + }, + new + { + Id = 11, + CoachId = 11, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 4, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "DEC" + }, + new + { + Id = 12, + CoachId = 12, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Leopards" + }, + new + { + Id = 13, + CoachId = 13, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Harlequins" + }, + new + { + Id = 14, + CoachId = 14, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 4, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Gladiators" + }, + new + { + Id = 15, + CoachId = 15, + CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), + LeagueId = 1, + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Fiz-O" + }); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b => + { + b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam") + .WithMany("AwayMatches") + .HasForeignKey("AwayTeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam") + .WithMany("HomeMatches") + .HasForeignKey("HomeTeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AwayTeam"); + + b.Navigation("HomeTeam"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => + { + b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach") + .WithOne("Team") + .HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkCore.Domain.League", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId"); + + b.Navigation("Coach"); + + b.Navigation("League"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b => + { + b.Navigation("Team"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.League", b => + { + b.Navigation("Teams"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => + { + b.Navigation("AwayMatches"); + + b.Navigation("HomeMatches"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.cs b/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.cs new file mode 100644 index 0000000..a2de00b --- /dev/null +++ b/EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.cs @@ -0,0 +1,472 @@ +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 }); + } + } +} diff --git a/EntityFrameworkCore.Data/Migrations/DeadBallZoneLeagueDbContextModelSnapshot.cs b/EntityFrameworkCore.Data/Migrations/DeadBallZoneLeagueDbContextModelSnapshot.cs index 8cc813c..9c53654 100644 --- a/EntityFrameworkCore.Data/Migrations/DeadBallZoneLeagueDbContextModelSnapshot.cs +++ b/EntityFrameworkCore.Data/Migrations/DeadBallZoneLeagueDbContextModelSnapshot.cs @@ -39,12 +39,116 @@ namespace EntityFrameworkCore.Data.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("TeamId") - .HasColumnType("INTEGER"); - b.HasKey("Id"); - b.ToTable("Coaches", (string)null); + b.ToTable("Coaches"); + + b.HasData( + new + { + Id = 1, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Christian Southgate" + }, + new + { + Id = 2, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Rob Mann" + }, + new + { + Id = 3, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Jon Curtis" + }, + new + { + Id = 4, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Andy Taylor" + }, + new + { + Id = 5, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Steve Johnson" + }, + new + { + Id = 6, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Dan Cook" + }, + new + { + Id = 7, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Ken Jarvis" + }, + new + { + Id = 8, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Kenny Suzuki" + }, + new + { + Id = 9, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Gordon Hall" + }, + new + { + Id = 10, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "John O Dowd" + }, + new + { + Id = 11, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Julian Widdows" + }, + new + { + Id = 12, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Andy Williams" + }, + new + { + Id = 13, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Trevor Williams" + }, + new + { + Id = 14, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Blake Deathray" + }, + new + { + Id = 15, + CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), + ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Name = "Rock Housebrick" + }); }); modelBuilder.Entity("EntityFrameworkCore.Domain.League", b => @@ -70,7 +174,7 @@ namespace EntityFrameworkCore.Data.Migrations b.HasKey("Id"); - b.ToTable("Leagues", (string)null); + b.ToTable("Leagues"); b.HasData( new @@ -112,6 +216,9 @@ namespace EntityFrameworkCore.Data.Migrations b.Property("AwayTeamId") .HasColumnType("INTEGER"); + b.Property("AwayTeamScore") + .HasColumnType("INTEGER"); + b.Property("CreatedBy") .HasColumnType("TEXT"); @@ -124,6 +231,9 @@ namespace EntityFrameworkCore.Data.Migrations b.Property("HomeTeamId") .HasColumnType("INTEGER"); + b.Property("HomeTeamScore") + .HasColumnType("INTEGER"); + b.Property("ModifiedBy") .HasColumnType("TEXT"); @@ -135,7 +245,11 @@ namespace EntityFrameworkCore.Data.Migrations b.HasKey("Id"); - b.ToTable("Matches", (string)null); + b.HasIndex("AwayTeamId"); + + b.HasIndex("HomeTeamId"); + + b.ToTable("Matches"); }); modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => @@ -153,7 +267,7 @@ namespace EntityFrameworkCore.Data.Migrations b.Property("CreatedDate") .HasColumnType("TEXT"); - b.Property("LeagueId") + b.Property("LeagueId") .HasColumnType("INTEGER"); b.Property("ModifiedBy") @@ -167,145 +281,206 @@ namespace EntityFrameworkCore.Data.Migrations b.HasKey("Id"); - b.ToTable("Teams", (string)null); + b.HasIndex("CoachId") + .IsUnique(); + + b.HasIndex("LeagueId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Teams"); b.HasData( new { Id = 1, - CoachId = 0, + CoachId = 1, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 2, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Delhi" }, new { Id = 2, - CoachId = 0, + CoachId = 2, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Voodoo" }, new { Id = 3, - CoachId = 0, + CoachId = 3, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Penal X" }, new { Id = 4, - CoachId = 0, + CoachId = 4, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 3, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Tokyo" }, new { Id = 5, - CoachId = 0, + CoachId = 5, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 2, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Barcelona" }, new { Id = 6, - CoachId = 0, + CoachId = 6, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 2, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Manchester" }, new { Id = 7, - CoachId = 0, + CoachId = 7, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 3, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Bangkok" }, new { Id = 8, - CoachId = 0, + CoachId = 8, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 3, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Neo Amsterdam" }, new { Id = 9, - CoachId = 0, + CoachId = 9, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Killaklowns" }, new { Id = 10, - CoachId = 0, + CoachId = 10, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Sol" }, new { Id = 11, - CoachId = 0, + CoachId = 11, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 4, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "DEC" }, new { Id = 12, - CoachId = 0, + CoachId = 12, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Leopards" }, new { Id = 13, - CoachId = 0, + CoachId = 13, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Harlequins" }, new { Id = 14, - CoachId = 0, + CoachId = 14, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 4, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Gladiators" }, new { Id = 15, - CoachId = 0, + CoachId = 15, CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified), - LeagueId = 0, + LeagueId = 1, ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Name = "Fiz-O" }); }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b => + { + b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam") + .WithMany("AwayMatches") + .HasForeignKey("AwayTeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam") + .WithMany("HomeMatches") + .HasForeignKey("HomeTeamId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AwayTeam"); + + b.Navigation("HomeTeam"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => + { + b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach") + .WithOne("Team") + .HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkCore.Domain.League", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId"); + + b.Navigation("Coach"); + + b.Navigation("League"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b => + { + b.Navigation("Team"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.League", b => + { + b.Navigation("Teams"); + }); + + modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b => + { + b.Navigation("AwayMatches"); + + b.Navigation("HomeMatches"); + }); #pragma warning restore 612, 618 } }