13d3aeab09
Phase 1b of the v2 entity-model rewrite. The design's live-edit model means
the 12 v2 live-edit entities no longer carry a generation scope — they're
edited directly via AdminOperationsActor, with RowVersion (added in Task 14a)
providing last-write-wins detection.
Entity changes (12 files):
Equipment, DriverInstance, Device, Tag, PollGroup, Namespace,
UnsArea, UnsLine, NodeAcl, Script, VirtualTag, ScriptedAlarm
- Removed: public long GenerationId
- Removed: public ConfigGeneration? Generation (navigation)
DbContext changes (OtOpcUaConfigDbContext.cs):
- Removed 12 HasOne(x => x.Generation).WithMany().HasForeignKey... mappings
- Rewrote ~36 indexes: dropped the GenerationId column from each composite
key, renamed UX_<Table>_Generation_<X> -> UX_<Table>_<X> and
IX_<Table>_Generation_<X> -> IX_<Table>_<X>. Logical IDs become globally
unique (UX_<Table>_LogicalId on the LogicalId column alone).
- Removed Namespace's redundant UX_Namespace_Generation_LogicalId_Cluster
index (subsumed by the new UX_Namespace_LogicalId).
Core.Tests fixtures (4 files):
Removed "GenerationId = 1," lines from:
- PermissionTrieBuilderTests.cs (NodeAcl Row factory)
- PermissionTrieTests.cs (NodeAcl Row factory)
- TriePermissionEvaluatorTests.cs (NodeAcl Row factory + 2 gen{1,5}Row
mutations that test stale-generation evaluation; the trie itself still
carries a generation tag via PermissionTrie.GenerationId, fed in via
PermissionTrieBuilder.Build's generationId parameter, so the tests
still exercise the production code path)
- EquipmentNodeWalkerTests.cs (Area/Line/Eq/Tag/VirtualTag/ScriptedAlarm
builders)
Expected breakage (accepted per Task 56 policy):
src/Server/ZB.MOM.WW.OtOpcUa.Server ~25 errors (DriverInstanceBootstrapper,
AuthorizationBootstrap,
EquipmentNamespaceContentLoader,
Phase7Composer, ...)
src/Server/ZB.MOM.WW.OtOpcUa.Admin ~45 errors (VirtualTags.razor,
ScriptedAlarms.razor,
DriverInstanceService,
EquipmentService,
EquipmentImportBatchService,
UnsService,
FocasDriverDetailService,
...)
Server.Tests, Admin.Tests, Admin.E2ETests also break transitively (they
project-reference Server/Admin). All deleted in Task 56.
Verification:
dotnet build src/Core/ZB.MOM.WW.OtOpcUa.Configuration -> 0 errors
dotnet build tests/Core/ZB.MOM.WW.OtOpcUa.Core.Tests -> 0 errors
dotnet build tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests -> 0 errors
dotnet build (whole solution) -> 70 errors, all in Server/Admin
39 lines
1.7 KiB
C#
39 lines
1.7 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
|
|
|
/// <summary>
|
|
/// Per Phase 7 plan decision #8 — user-authored C# script source, referenced by
|
|
/// <see cref="VirtualTag"/> and <see cref="ScriptedAlarm"/>. One row per script,
|
|
/// per generation. <c>SourceHash</c> is the compile-cache key.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Scripts are generation-scoped: a draft's edit creates a new row in the draft
|
|
/// generation, the old row stays frozen in the published generation. Shape mirrors
|
|
/// the other generation-scoped entities (Equipment, Tag, etc.) — <c>ScriptId</c> is
|
|
/// the stable logical id that carries across generations; <c>ScriptRowId</c> is the
|
|
/// row identity.
|
|
/// </para>
|
|
/// </remarks>
|
|
public sealed class Script
|
|
{
|
|
public Guid ScriptRowId { get; set; }
|
|
|
|
/// <summary>Stable logical id. Globally unique in v2.</summary>
|
|
public required string ScriptId { get; set; }
|
|
|
|
/// <summary>Operator-friendly name for log filtering + Admin UI list view.</summary>
|
|
public required string Name { get; set; }
|
|
|
|
/// <summary>Raw C# source. Size bounded by the DB column (nvarchar(max)).</summary>
|
|
public required string SourceCode { get; set; }
|
|
|
|
/// <summary>SHA-256 of <see cref="SourceCode"/> — compile-cache key for Phase 7 Stream A's <c>CompiledScriptCache</c>.</summary>
|
|
public required string SourceHash { get; set; }
|
|
|
|
/// <summary>Language — always "CSharp" today; placeholder for future engines (Python/Lua).</summary>
|
|
public string Language { get; set; } = "CSharp";
|
|
|
|
/// <summary>Optimistic concurrency token for last-write-wins detection in the v2 live-edit model.</summary>
|
|
public byte[] RowVersion { get; set; } = Array.Empty<byte>();
|
|
}
|