Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Configurations/NotificationOutboxConfiguration.cs
T
Joseph Doherty 7b0b9c7365 refactor: rename ScadaLink → ZB.MOM.WW.ScadaBridge (code + projects + namespaces)
Solution + 23 src projects + 26 test projects renamed; folders, csproj,
namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated.
ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated.
SQL roles/logins, LDAP domains, CLI command name, and CLI config dir
(~/.scadalink → ~/.scadabridge) also renamed.

Build green; 5 Host.Tests fail awaiting SQL login rename in next commit.
Pre-existing StaleTagMonitor timing flakes unchanged.

Rename script committed at tools/rename-to-scadabridge.sh.
2026-05-28 09:37:45 -04:00

75 lines
3.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Configurations;
/// <summary>
/// EF Core mapping for the central notification outbox entity. <see cref="Notification.TypeData"/>
/// and <see cref="Notification.ResolvedTargets"/> are intentionally left unconstrained
/// (nullable nvarchar(max)) as they carry variable-length JSON / target snapshots.
/// </summary>
public class NotificationOutboxConfiguration : IEntityTypeConfiguration<Notification>
{
/// <summary>Configures the EF Core entity type mapping for <see cref="Notification"/>.</summary>
/// <param name="builder">The entity type builder to configure.</param>
public void Configure(EntityTypeBuilder<Notification> builder)
{
builder.HasKey(n => n.NotificationId);
builder.Property(n => n.NotificationId).HasMaxLength(64);
builder.Property(n => n.Type)
.HasConversion<string>()
.HasMaxLength(32)
.IsRequired();
builder.Property(n => n.Status)
.HasConversion<string>()
.HasMaxLength(32)
.IsRequired();
builder.Property(n => n.ListName)
.HasMaxLength(200)
.IsRequired();
builder.Property(n => n.Subject)
.HasMaxLength(1000)
.IsRequired();
builder.Property(n => n.Body).IsRequired();
builder.Property(n => n.LastError).HasMaxLength(4000);
builder.Property(n => n.SourceSiteId)
.HasMaxLength(100)
.IsRequired();
builder.Property(n => n.SourceInstanceId).HasMaxLength(200);
builder.Property(n => n.SourceScript).HasMaxLength(200);
// SourceNode (Audit Log #23, SourceNode-stamping): node-local identifier of the
// cluster member that produced the notification (e.g. "node-a", "central-a").
// NULL is valid for rows that pre-date this feature. ASCII — varchar(64).
// No index — KPIs are per-site on this table, not per-node; SourceNode is only
// echoed onto NotifyDeliver audit rows (#23) for cross-row correlation.
builder.Property(n => n.SourceNode)
.HasColumnType("varchar(64)")
.HasMaxLength(64)
.IsUnicode(false);
// OriginExecutionId (Audit Log #23): nullable uniqueidentifier carried from the
// site so the dispatcher can echo it onto NotifyDeliver audit rows. No index —
// it is never a query predicate on this table, only copied onto audit events.
// OriginParentExecutionId (Audit Log #23): nullable uniqueidentifier carried from
// the site — the routed run's parent ExecutionId — so the dispatcher can echo it
// onto NotifyDeliver audit rows. No index — same rationale as OriginExecutionId.
builder.HasIndex(n => new { n.Status, n.NextAttemptAt });
builder.HasIndex(n => new { n.SourceSiteId, n.CreatedAt });
}
}