Add migration to make relation League to Team nullable.

This commit is contained in:
Kevin Matsubara 2025-04-07 10:45:09 +02:00
parent e852f09f09
commit 42edf6cccf
3 changed files with 587 additions and 19 deletions

View File

@ -0,0 +1,316 @@
// <auto-generated />
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("20250407084418_MakeRelationshipLeagueToTeamNullable")]
partial class MakeRelationshipLeagueToTeamNullable
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("TeamId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Coaches");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AwayTeamId")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("HomeTeamId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<decimal>("TicketPrice")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Matches");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<int?>("LeagueId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedDate")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("LeagueId");
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi"
},
new
{
Id = 2,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo"
},
new
{
Id = 3,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X"
},
new
{
Id = 4,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo"
},
new
{
Id = 5,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona"
},
new
{
Id = 6,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester"
},
new
{
Id = 7,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok"
},
new
{
Id = 8,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam"
},
new
{
Id = 9,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns"
},
new
{
Id = 10,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol"
},
new
{
Id = 11,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC"
},
new
{
Id = 12,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards"
},
new
{
Id = 13,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins"
},
new
{
Id = 14,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators"
},
new
{
Id = 15,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,269 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class MakeRelationshipLeagueToTeamNullable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams");
migrationBuilder.AlterColumn<int>(
name: "LeagueId",
table: "Teams",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 1,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 2,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 3,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 4,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 5,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 6,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 7,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 8,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 9,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 10,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 11,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 12,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 13,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 14,
column: "LeagueId",
value: null);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 15,
column: "LeagueId",
value: null);
migrationBuilder.AddForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams",
column: "LeagueId",
principalTable: "Leagues",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams");
migrationBuilder.AlterColumn<int>(
name: "LeagueId",
table: "Teams",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 1,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 2,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 3,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 4,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 5,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 6,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 7,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 8,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 9,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 10,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 11,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 12,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 13,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 14,
column: "LeagueId",
value: 0);
migrationBuilder.UpdateData(
table: "Teams",
keyColumn: "Id",
keyValue: 15,
column: "LeagueId",
value: 0);
migrationBuilder.AddForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams",
column: "LeagueId",
principalTable: "Leagues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -153,7 +153,7 @@ namespace EntityFrameworkCore.Data.Migrations
b.Property<DateTime>("CreatedDate")
.HasColumnType("TEXT");
b.Property<int>("LeagueId")
b.Property<int?>("LeagueId")
.HasColumnType("INTEGER");
b.Property<string>("ModifiedBy")
@ -177,7 +177,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 1,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Delhi"
},
@ -186,7 +185,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 2,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Voodoo"
},
@ -195,7 +193,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 3,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Penal X"
},
@ -204,7 +201,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 4,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Tokyo"
},
@ -213,7 +209,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 5,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Barcelona"
},
@ -222,7 +217,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 6,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Manchester"
},
@ -231,7 +225,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 7,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Bangkok"
},
@ -240,7 +233,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 8,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Neo Amsterdam"
},
@ -249,7 +241,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 9,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Killaklowns"
},
@ -258,7 +249,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 10,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Sol"
},
@ -267,7 +257,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 11,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "DEC"
},
@ -276,7 +265,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 12,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Leopards"
},
@ -285,7 +273,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 13,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Harlequins"
},
@ -294,7 +281,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 14,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Gladiators"
},
@ -303,7 +289,6 @@ namespace EntityFrameworkCore.Data.Migrations
Id = 15,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
LeagueId = 0,
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O"
});
@ -313,9 +298,7 @@ namespace EntityFrameworkCore.Data.Migrations
{
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("LeagueId");
b.Navigation("League");
});