7b0b9c7365
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.
58 lines
2.3 KiB
C#
58 lines
2.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Migrations
|
|
{
|
|
/// <summary>
|
|
/// Adds the universal <c>ExecutionId</c> correlation column to the centralized
|
|
/// <c>AuditLog</c> table (#23). <c>ExecutionId</c> identifies the originating
|
|
/// script execution / inbound request and is distinct from the per-operation
|
|
/// <c>CorrelationId</c>.
|
|
///
|
|
/// The change is purely additive:
|
|
/// 1. <c>ExecutionId uniqueidentifier NULL</c> is added with no default, so the
|
|
/// operation is a metadata-only <c>ALTER TABLE … ADD</c> — it does NOT
|
|
/// rewrite the monthly-partitioned <c>AuditLog</c> table, and historical
|
|
/// rows stay <c>NULL</c> (no backfill).
|
|
/// 2. <c>IX_AuditLog_Execution</c> is created via raw SQL so it lands on the
|
|
/// <c>ps_AuditLog_Month(OccurredAtUtc)</c> partition scheme, matching every
|
|
/// other <c>IX_AuditLog_*</c> index. Keeping it partition-aligned preserves
|
|
/// the partition-switch purge path (see AuditLogRepository.SwitchOutPartitionAsync).
|
|
/// </summary>
|
|
public partial class AddAuditLogExecutionId : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "ExecutionId",
|
|
table: "AuditLog",
|
|
type: "uniqueidentifier",
|
|
nullable: true);
|
|
|
|
// Raw SQL so the index is created on the partition scheme — EF's
|
|
// CreateIndex cannot express the ON ps_AuditLog_Month(OccurredAtUtc)
|
|
// clause. Mirrors IX_AuditLog_CorrelationId (filtered, aligned).
|
|
migrationBuilder.Sql(@"
|
|
CREATE NONCLUSTERED INDEX IX_AuditLog_Execution
|
|
ON dbo.AuditLog (ExecutionId)
|
|
WHERE ExecutionId IS NOT NULL
|
|
ON ps_AuditLog_Month(OccurredAtUtc);");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.Sql(@"
|
|
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_AuditLog_Execution' AND object_id = OBJECT_ID('dbo.AuditLog'))
|
|
DROP INDEX IX_AuditLog_Execution ON dbo.AuditLog;");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ExecutionId",
|
|
table: "AuditLog");
|
|
}
|
|
}
|
|
}
|