Search/AdvisoryAI and DAL conversion to EF finishes up. Preparation for microservices consolidation.
This commit is contained in:
@@ -5,21 +5,31 @@ namespace StellaOps.Integrations.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// EF Core DbContext for Integration persistence.
|
||||
/// SQL migrations remain authoritative; EF models are scaffolded FROM schema.
|
||||
/// </summary>
|
||||
public sealed class IntegrationDbContext : DbContext
|
||||
public partial class IntegrationDbContext : DbContext
|
||||
{
|
||||
public IntegrationDbContext(DbContextOptions<IntegrationDbContext> options)
|
||||
public const string DefaultSchemaName = "integrations";
|
||||
|
||||
private readonly string _schemaName;
|
||||
|
||||
public IntegrationDbContext(DbContextOptions<IntegrationDbContext> options, string? schemaName = null)
|
||||
: base(options)
|
||||
{
|
||||
_schemaName = string.IsNullOrWhiteSpace(schemaName)
|
||||
? DefaultSchemaName
|
||||
: schemaName.Trim();
|
||||
}
|
||||
|
||||
public DbSet<IntegrationEntity> Integrations => Set<IntegrationEntity>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
var schemaName = _schemaName;
|
||||
|
||||
modelBuilder.Entity<IntegrationEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("integrations");
|
||||
entity.ToTable("integrations", schemaName);
|
||||
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
@@ -53,7 +63,11 @@ public sealed class IntegrationDbContext : DbContext
|
||||
entity.HasIndex(e => e.TenantId);
|
||||
entity.HasIndex(e => new { e.TenantId, e.Name }).IsUnique().HasFilter("is_deleted = false");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user