diff --git a/build.md b/build.md index 3118f77..de08035 100644 --- a/build.md +++ b/build.md @@ -7,17 +7,16 @@ dotnet tool update --global dotnet-ef --version 9.0.11 ## Update-DB: ``` -dotnet ef migrations add [KEYWORDABOUTCHANGE] --project src/AIMS.Infrastructure --startup-project src/AIMS.Web +dotnet ef migrations add [Initial_App] --project src/Koogle.Infrastructure --startup-project src/Koogle.Web --context AppDbContext --output-dir Data/Migrations +dotnet ef database update -p src/Koogle.Infrastructure -s src/Koogle.Web --context AppDbContext -dotnet ef migrations add Initial_App --project src/Koogle.Infrastructure --startup-project src/Koogle.Web --context AppDbContext --output-dir Data/Migrations - - -dotnet ef migrations add Initial_Auth --project src/Koogle.Infrastructure --startup-project src/Koogle.Web --context AppIdentityDbContext --output-dir Identity/Migrations +dotnet ef migrations add [Initial_Auth] --project src/Koogle.Infrastructure --startup-project src/Koogle.Web --context AppIdentityDbContext --output-dir Identity/Migrations -dotnet ef database update -p src/AIMS.Infrastructure -s src/AIMS.Web +dotnet ef database update -p src/Koogle.Infrastructure -s src/Koogle.Web --context AppIdentityDbContext +dotnet ef database update -p src/Koogle.Infrastructure -s src/Koogle.Web --context AppDbContext ``` diff --git a/src/Koogle.Infrastructure/Data/Configurations/DayPersonConfiguration.cs b/src/Koogle.Infrastructure/Data/Configurations/DayPersonConfiguration.cs index 6a88a67..c3f3dfc 100644 --- a/src/Koogle.Infrastructure/Data/Configurations/DayPersonConfiguration.cs +++ b/src/Koogle.Infrastructure/Data/Configurations/DayPersonConfiguration.cs @@ -41,6 +41,23 @@ public class DayPersonConfiguration : IEntityTypeConfiguration .HasPrincipalKey(p => new { p.Id, p.ClubId }) .OnDelete(DeleteBehavior.Cascade); + + + builder.HasIndex(x => x.ClubId); + builder.HasIndex(x => x.DayId); + builder.HasIndex(x => x.PersonId); + + + // ✅ Matching Query Filter(verhindert die Warnung 10622) + // DayPerson wird automatisch ausgeblendet, wenn Club/Day/Person soft-deleted ist. + builder.HasQueryFilter(dp => + !dp.Day.IsDeleted && + !dp.Person.IsDeleted && + !dp.Club.IsDeleted + ); + + + builder.HasIndex(x => x.ClubId); builder.HasIndex(x => x.DayId); builder.HasIndex(x => x.PersonId); diff --git a/src/Koogle.Infrastructure/Data/Configurations/ExpenseTriggerConfiguration.cs b/src/Koogle.Infrastructure/Data/Configurations/ExpenseTriggerConfiguration.cs index eda721a..06475d9 100644 --- a/src/Koogle.Infrastructure/Data/Configurations/ExpenseTriggerConfiguration.cs +++ b/src/Koogle.Infrastructure/Data/Configurations/ExpenseTriggerConfiguration.cs @@ -49,6 +49,15 @@ public class ExpenseTriggerConfiguration : IEntityTypeConfiguration x.TriggerId); builder.HasIndex(x => x.ClubId); + + // ✅ Matching Query Filter: Zuordnung verschwindet automatisch, + // wenn Club/Expense/Trigger soft-deleted sind. + builder.HasQueryFilter(et => + !et.Club.IsDeleted && + !et.Expense.IsDeleted && + !et.Trigger.IsDeleted + ); + } } diff --git a/src/Koogle.Infrastructure/Data/Configurations/GamePersonConfiguration.cs b/src/Koogle.Infrastructure/Data/Configurations/GamePersonConfiguration.cs index 571d9c7..efc0161 100644 --- a/src/Koogle.Infrastructure/Data/Configurations/GamePersonConfiguration.cs +++ b/src/Koogle.Infrastructure/Data/Configurations/GamePersonConfiguration.cs @@ -28,6 +28,16 @@ public class GamePersonConfiguration : IEntityTypeConfiguration .OnDelete(DeleteBehavior.Cascade); builder.HasIndex(x => x.PersonId); + + + // ✅ Matching Query Filter: + // GamePerson nur sichtbar, wenn Game + Person + Day des Games nicht soft-deleted sind. + builder.HasQueryFilter(gp => + !gp.Game.IsDeleted && + !gp.Person.IsDeleted && + !gp.Game.Day.IsDeleted + ); + } } diff --git a/src/Koogle.Infrastructure/Data/Configurations/PersonExpenseConfiguration.cs b/src/Koogle.Infrastructure/Data/Configurations/PersonExpenseConfiguration.cs index 09a7f87..20a6763 100644 --- a/src/Koogle.Infrastructure/Data/Configurations/PersonExpenseConfiguration.cs +++ b/src/Koogle.Infrastructure/Data/Configurations/PersonExpenseConfiguration.cs @@ -63,7 +63,16 @@ public class PersonExpenseConfiguration : IEntityTypeConfiguration x.DayId); builder.HasIndex(x => x.GameId); - builder.HasQueryFilter(x => !x.IsDeleted); + + builder.HasQueryFilter(pe => + // required Principals müssen sichtbar sein + !pe.Person.IsDeleted && + !pe.Day.IsDeleted && + !pe.Expense.IsDeleted && + // optionales Game: entweder kein Game, oder Game + dessen Day sichtbar + (pe.GameId == null || (!pe.Game!.IsDeleted && !pe.Game!.Day.IsDeleted)) + ); + } } diff --git a/src/Koogle.Infrastructure/Data/Configurations/UserProfileClubConfiguration.cs b/src/Koogle.Infrastructure/Data/Configurations/UserProfileClubConfiguration.cs index 538ca0d..9dd60d7 100644 --- a/src/Koogle.Infrastructure/Data/Configurations/UserProfileClubConfiguration.cs +++ b/src/Koogle.Infrastructure/Data/Configurations/UserProfileClubConfiguration.cs @@ -41,5 +41,13 @@ public class UserProfileClubConfiguration : IEntityTypeConfiguration x.ClubId); + + // ✅ Matching Query Filter + builder.HasQueryFilter(upc => + !upc.UserProfile.IsDeleted && + !upc.Club.IsDeleted + ); + + } } diff --git a/src/Koogle.Infrastructure/Data/Migrations/20251221085745_Initial_App.Designer.cs b/src/Koogle.Infrastructure/Data/Migrations/20251221103855_Initial_App.Designer.cs similarity index 99% rename from src/Koogle.Infrastructure/Data/Migrations/20251221085745_Initial_App.Designer.cs rename to src/Koogle.Infrastructure/Data/Migrations/20251221103855_Initial_App.Designer.cs index bea5806..d739325 100644 --- a/src/Koogle.Infrastructure/Data/Migrations/20251221085745_Initial_App.Designer.cs +++ b/src/Koogle.Infrastructure/Data/Migrations/20251221103855_Initial_App.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Koogle.Infrastructure.Data.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20251221085745_Initial_App")] + [Migration("20251221103855_Initial_App")] partial class Initial_App { /// diff --git a/src/Koogle.Infrastructure/Data/Migrations/20251221085745_Initial_App.cs b/src/Koogle.Infrastructure/Data/Migrations/20251221103855_Initial_App.cs similarity index 100% rename from src/Koogle.Infrastructure/Data/Migrations/20251221085745_Initial_App.cs rename to src/Koogle.Infrastructure/Data/Migrations/20251221103855_Initial_App.cs