28 lines
989 B
C#
28 lines
989 B
C#
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using TeamUp.Modules.Governance.Domain;
|
||
|
|
using TeamUp.SharedKernel.Persistence;
|
||
|
|
|
||
|
|
namespace TeamUp.Modules.Governance.Persistence;
|
||
|
|
|
||
|
|
internal sealed class GovernanceDbContext(DbContextOptions<GovernanceDbContext> options)
|
||
|
|
: DbContext(options), IModuleDbContext
|
||
|
|
{
|
||
|
|
public DbSet<AuditEntry> AuditEntries => Set<AuditEntry>();
|
||
|
|
|
||
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||
|
|
{
|
||
|
|
modelBuilder.HasDefaultSchema("governance");
|
||
|
|
|
||
|
|
modelBuilder.Entity<AuditEntry>(entry =>
|
||
|
|
{
|
||
|
|
entry.ToTable("audit_entries");
|
||
|
|
entry.HasKey(a => a.Id);
|
||
|
|
entry.Property(a => a.Action).HasMaxLength(100).IsRequired();
|
||
|
|
entry.Property(a => a.EntityType).HasMaxLength(100).IsRequired();
|
||
|
|
entry.Property(a => a.Details).HasMaxLength(2000);
|
||
|
|
entry.HasIndex(a => a.OccurredAtUtc);
|
||
|
|
entry.HasIndex(a => new { a.EntityType, a.EntityId });
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|