refactor(infra): register auditable interceptor via DI

Register AuditableEntityInterceptor as a singleton and attach it through the
AddDbContext options callback instead of newing it up inside
Database.OnConfiguring. The interceptor is stateless, so a single shared
instance is reused across contexts and its wiring lives in the DI layer.
The design-time factory keeps working (interceptor is runtime-only, irrelevant
for migrations).

Verified: build + ef migrations list (design-time context) OK; the Worker host
builds and validates the full DI graph (reaches endpoint configuration) with no
captive-dependency or interceptor error.

Build: 0 warnings, 0 errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 15:14:03 +02:00
co-authored by Claude Opus 4.8
parent c2258569a0
commit 431b56a072
2 changed files with 6 additions and 2 deletions
@@ -15,7 +15,6 @@ namespace Musify.Infrastructure.Persistence
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(configuration.ConnectionString);
optionsBuilder.AddInterceptors(new AuditableEntityInterceptor());
}
protected override void OnModelCreating(ModelBuilder modelBuilder)