feat(historian): SQL Server backend skeleton - schema DDL, locked bootstrapper, options, connection/mapper/tag-catalog helpers, status consts, env-gated fixture

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-09 12:52:15 -04:00
parent ff7c6c531a
commit 17962d4233
19 changed files with 1187 additions and 0 deletions
@@ -0,0 +1,32 @@
using Shouldly;
using Xunit;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer.Tests;
public sealed class SchemaScriptTests
{
[Fact]
public void Go_splitting_ignores_go_inside_other_text_and_drops_empties()
{
var parts = SqlServerSchemaBootstrapper.SplitBatches("A\nGO\n go \nB GO C\nGO\n").ToArray();
parts.ShouldBe(["A", "B GO C"]);
}
[Fact]
public void Embedded_script_is_present_and_matches_the_docs_copy()
{
var asm = typeof(SqlServerSchemaBootstrapper).Assembly;
using var s = asm.GetManifestResourceStream("Schema.001_initial.sql");
s.ShouldNotBeNull();
var text = new StreamReader(s!).ReadToEnd();
text.ShouldContain("$(Schema)");
text.ShouldContain("PRIMARY KEY NONCLUSTERED");
text.ShouldContain("CREATE CLUSTERED INDEX CX_Event_Time");
text.ShouldNotContain("IX_Event_Time");
var dir = new DirectoryInfo(AppContext.BaseDirectory);
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ZB.MOM.WW.OtOpcUa.slnx"))) dir = dir.Parent;
dir.ShouldNotBeNull();
File.ReadAllText(Path.Combine(dir!.FullName, "docs/historian/sqlserver/001_initial.sql")).ShouldBe(text);
}
}