fix datamodel
This commit is contained in:
parent
6c43c85cb4
commit
d653225c5f
11
build.md
11
build.md
|
|
@ -7,17 +7,16 @@ dotnet tool update --global dotnet-ef --version 9.0.11
|
||||||
|
|
||||||
## Update-DB:
|
## 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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,23 @@ public class DayPersonConfiguration : IEntityTypeConfiguration<DayPerson>
|
||||||
.HasPrincipalKey(p => new { p.Id, p.ClubId })
|
.HasPrincipalKey(p => new { p.Id, p.ClubId })
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.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.ClubId);
|
||||||
builder.HasIndex(x => x.DayId);
|
builder.HasIndex(x => x.DayId);
|
||||||
builder.HasIndex(x => x.PersonId);
|
builder.HasIndex(x => x.PersonId);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,15 @@ public class ExpenseTriggerConfiguration : IEntityTypeConfiguration<ExpenseTrigg
|
||||||
builder.HasIndex(x => x.TriggerId);
|
builder.HasIndex(x => x.TriggerId);
|
||||||
builder.HasIndex(x => x.ClubId);
|
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
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,16 @@ public class GamePersonConfiguration : IEntityTypeConfiguration<GamePerson>
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
builder.HasIndex(x => x.PersonId);
|
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
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,16 @@ public class PersonExpenseConfiguration : IEntityTypeConfiguration<PersonExpense
|
||||||
builder.HasIndex(x => x.DayId);
|
builder.HasIndex(x => x.DayId);
|
||||||
builder.HasIndex(x => x.GameId);
|
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))
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,13 @@ public class UserProfileClubConfiguration : IEntityTypeConfiguration<UserProfile
|
||||||
|
|
||||||
builder.HasIndex(x => x.ClubId);
|
builder.HasIndex(x => x.ClubId);
|
||||||
|
|
||||||
|
|
||||||
|
// ✅ Matching Query Filter
|
||||||
|
builder.HasQueryFilter(upc =>
|
||||||
|
!upc.UserProfile.IsDeleted &&
|
||||||
|
!upc.Club.IsDeleted
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
namespace Koogle.Infrastructure.Data.Migrations
|
namespace Koogle.Infrastructure.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20251221085745_Initial_App")]
|
[Migration("20251221103855_Initial_App")]
|
||||||
partial class Initial_App
|
partial class Initial_App
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
Loading…
Reference in New Issue