f57f61deac
ConfigAuditLog gains two nullable columns (EventId, CorrelationId) + a filtered unique index UX_ConfigAuditLog_EventId. EF migration 20260526105027_AddConfigAuditLogEventIdColumns is additive (nullable + filtered index = legacy rows backfill cleanly). AuditWriterActor now writes EventId + CorrelationId into the dedicated columns instead of synthesising a JSON wrapper into DetailsJson. Cross-restart dedup is now real: a retry of an already-flushed batch hits the unique index and SaveChanges throws; the existing catch drops the duplicate without losing the rest of the batch. WrapDetails helper deleted — F4 (its JSON hardening) becomes moot. AuditWriterActorTests.Details_wrapper_embeds_eventId_and_correlationId renamed + rewritten to assert against the columns. All 29 ControlPlane tests pass, all 95 v2 tests green.
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddConfigAuditLogEventIdColumns : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "CorrelationId",
|
|
table: "ConfigAuditLog",
|
|
type: "uniqueidentifier",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "EventId",
|
|
table: "ConfigAuditLog",
|
|
type: "uniqueidentifier",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "UX_ConfigAuditLog_EventId",
|
|
table: "ConfigAuditLog",
|
|
column: "EventId",
|
|
unique: true,
|
|
filter: "[EventId] IS NOT NULL");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropIndex(
|
|
name: "UX_ConfigAuditLog_EventId",
|
|
table: "ConfigAuditLog");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CorrelationId",
|
|
table: "ConfigAuditLog");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "EventId",
|
|
table: "ConfigAuditLog");
|
|
}
|
|
}
|
|
}
|