feat(configdb): add SiteCalls migration (#22, #23 M3)

Bundle B2 of Audit Log #23 M3: EF-generated migration that creates the
SiteCalls operational-state table on [PRIMARY], with the simple clustered
PK on TrackedOperationId and the two named indexes the entity config
declares.

No partition function / scheme / DB-role restriction — SiteCalls holds
mutable operational state (insert-once + monotonic-status update at the
repo layer), unlike the partitioned append-only AuditLog table from M1.

- Migration: 20260520180431_AddSiteCallsTable.cs (auto-generated;
  EF emitted CREATE TABLE + 2 indexes without customisation needed).
- Model snapshot updated alongside.
- Integration test: tests/ScadaLink.ConfigurationDatabase.Tests/Migrations/
  AddSiteCallsTableMigrationTests.cs. Uses the existing MsSqlMigrationFixture
  with [SkippableFact] + Skip.IfNot(fixture.Available). Asserts table +
  twelve columns + PK on TrackedOperationId + both named indexes.
This commit is contained in:
Joseph Doherty
2026-05-20 14:05:36 -04:00
parent 3162286ade
commit 6667f345fa
4 changed files with 1866 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ScadaLink.ConfigurationDatabase.Migrations
{
/// <inheritdoc />
public partial class AddSiteCallsTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SiteCalls",
columns: table => new
{
TrackedOperationId = table.Column<string>(type: "varchar(36)", unicode: false, maxLength: 36, nullable: false),
Channel = table.Column<string>(type: "varchar(32)", unicode: false, maxLength: 32, nullable: false),
Target = table.Column<string>(type: "varchar(256)", unicode: false, maxLength: 256, nullable: false),
SourceSite = table.Column<string>(type: "varchar(64)", unicode: false, maxLength: 64, nullable: false),
Status = table.Column<string>(type: "varchar(32)", unicode: false, maxLength: 32, nullable: false),
RetryCount = table.Column<int>(type: "int", nullable: false),
LastError = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
HttpStatus = table.Column<int>(type: "int", nullable: true),
CreatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
TerminalAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true),
IngestedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SiteCalls", x => x.TrackedOperationId);
});
migrationBuilder.CreateIndex(
name: "IX_SiteCalls_Source_Created",
table: "SiteCalls",
columns: new[] { "SourceSite", "CreatedAtUtc" },
descending: new[] { false, true });
migrationBuilder.CreateIndex(
name: "IX_SiteCalls_Status_Updated",
table: "SiteCalls",
columns: new[] { "Status", "UpdatedAtUtc" },
descending: new[] { false, true });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SiteCalls");
}
}
}

View File

@@ -212,6 +212,72 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
b.ToTable("AuditLogEntries");
});
modelBuilder.Entity("ScadaLink.Commons.Entities.Audit.SiteCall", b =>
{
b.Property<string>("TrackedOperationId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("Channel")
.IsRequired()
.HasMaxLength(32)
.IsUnicode(false)
.HasColumnType("varchar(32)");
b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");
b.Property<int?>("HttpStatus")
.HasColumnType("int");
b.Property<DateTime>("IngestedAtUtc")
.HasColumnType("datetime2");
b.Property<string>("LastError")
.HasMaxLength(1024)
.HasColumnType("nvarchar(1024)");
b.Property<int>("RetryCount")
.HasColumnType("int");
b.Property<string>("SourceSite")
.IsRequired()
.HasMaxLength(64)
.IsUnicode(false)
.HasColumnType("varchar(64)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(32)
.IsUnicode(false)
.HasColumnType("varchar(32)");
b.Property<string>("Target")
.IsRequired()
.HasMaxLength(256)
.IsUnicode(false)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("TerminalAtUtc")
.HasColumnType("datetime2");
b.Property<DateTime>("UpdatedAtUtc")
.HasColumnType("datetime2");
b.HasKey("TrackedOperationId");
b.HasIndex("SourceSite", "CreatedAtUtc")
.IsDescending(false, true)
.HasDatabaseName("IX_SiteCalls_Source_Created");
b.HasIndex("Status", "UpdatedAtUtc")
.IsDescending(false, true)
.HasDatabaseName("IX_SiteCalls_Status_Updated");
b.ToTable("SiteCalls", (string)null);
});
modelBuilder.Entity("ScadaLink.Commons.Entities.Deployment.DeployedConfigSnapshot", b =>
{
b.Property<int>("Id")