Files
lmxopcua/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/20260526081556_V2HostingAlignment.cs
T
Joseph Doherty 605dbf3dcc feat(configdb): V2HostingAlignment migration consolidating Phase 1a-1e
Phase 1f — the consolidator migration. Closes out the v2 entity-model
rewrite by emitting a single EF migration that captures the cumulative
schema delta from 14a (RowVersion) through 14e (drop generation entities).

Generated: src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/
              20260526081556_V2HostingAlignment.cs           (1562 lines)
              20260526081556_V2HostingAlignment.Designer.cs

Migration shape (per `grep -nE migrationBuilder.\(...)`):

  Drop  12 ForeignKey constraints (one per live-edit entity's GenerationId FK)
  Drop  2  Tables  (ConfigGeneration, ClusterNodeGenerationState)
  Drop  45 Indexes (every UX_*_Generation_* and IX_*_Generation_* across the
                    13 live-edit tables — 1 also dropped the unique-Primary
                    filtered index UX_ClusterNode_Primary_Per_Cluster)
  Drop  13 Columns (12 GenerationId + 1 RedundancyRole)
  Add   12 RowVersion columns (one per live-edit entity)
  Create 4  Tables (Deployment, NodeDeploymentState, ConfigEdit,
                    DataProtectionKeys)
  Create ~45 Indexes (recreated under the new naming pattern
                      UX_<Table>_LogicalId / UX_<Table>_<X> with the
                      GenerationId column stripped from composite keys)

Notable EF quirks accepted:
  Unique-on-required-column indexes (UX_VirtualTag_LogicalId etc.) ship a
  `filter: "[VirtualTagId] IS NOT NULL"` clause that EF auto-inserts for
  SQL Server. Harmless — the column is C#-side `required` so NULL never
  appears.

Verification:
  dotnet build src/Core/ZB.MOM.WW.OtOpcUa.Configuration          -> 0 errors
  dotnet ef migrations script --idempotent (against placeholder DSN)
                                                                 -> 3259-line
                                                                    .sql produced
                                                                    OK
  tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests                -> 0 errors

Live `dotnet ef database update` against a scratch SQL Server deferred to
Task 15 (Migrate-To-V2.ps1) — SSH to the docker host needs a key/password I
don't have, and the always-on SQL at 10.100.0.35,14330 uses Integrated
Security (Windows auth, unreachable from this macOS dev). The migration
itself is structurally correct by construction (EF tooling generated it
against the live DbContext model); the live-DB confidence step is the
PowerShell wrapper's job.

SchemaComplianceTests updates:
  - All_expected_tables_exist: removed ConfigGeneration +
    ClusterNodeGenerationState; added Deployment, NodeDeploymentState,
    ConfigEdit, DataProtectionKeys.
  - Filtered_unique_indexes_match_schema_spec: removed entries for
    UX_ClusterNode_Primary_Per_Cluster (Task 14d) and
    UX_ConfigGeneration_Draft_Per_Cluster (Task 14e). Two filtered uniques
    remain (UX_ClusterNodeCredential_Value, UX_ExternalIdReservation_KindValue_Active).
  - Check_constraints_match_schema_spec: added CK_ConfigEdit_FieldsJson_IsJson.

StoredProceduresTests update:
  - Removed RedundancyRole + 'Primary' from the raw INSERT into ClusterNode
    so the DB-backed test runs against the new schema.
2026-05-26 04:18:50 -04:00

1563 lines
58 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
{
/// <inheritdoc />
public partial class V2HostingAlignment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Device_ConfigGeneration_GenerationId",
table: "Device");
migrationBuilder.DropForeignKey(
name: "FK_DriverInstance_ConfigGeneration_GenerationId",
table: "DriverInstance");
migrationBuilder.DropForeignKey(
name: "FK_Equipment_ConfigGeneration_GenerationId",
table: "Equipment");
migrationBuilder.DropForeignKey(
name: "FK_Namespace_ConfigGeneration_GenerationId",
table: "Namespace");
migrationBuilder.DropForeignKey(
name: "FK_NodeAcl_ConfigGeneration_GenerationId",
table: "NodeAcl");
migrationBuilder.DropForeignKey(
name: "FK_PollGroup_ConfigGeneration_GenerationId",
table: "PollGroup");
migrationBuilder.DropForeignKey(
name: "FK_Script_ConfigGeneration_GenerationId",
table: "Script");
migrationBuilder.DropForeignKey(
name: "FK_ScriptedAlarm_ConfigGeneration_GenerationId",
table: "ScriptedAlarm");
migrationBuilder.DropForeignKey(
name: "FK_Tag_ConfigGeneration_GenerationId",
table: "Tag");
migrationBuilder.DropForeignKey(
name: "FK_UnsArea_ConfigGeneration_GenerationId",
table: "UnsArea");
migrationBuilder.DropForeignKey(
name: "FK_UnsLine_ConfigGeneration_GenerationId",
table: "UnsLine");
migrationBuilder.DropForeignKey(
name: "FK_VirtualTag_ConfigGeneration_GenerationId",
table: "VirtualTag");
migrationBuilder.DropTable(
name: "ClusterNodeGenerationState");
migrationBuilder.DropTable(
name: "ConfigGeneration");
migrationBuilder.DropIndex(
name: "IX_VirtualTag_Generation_Script",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "UX_VirtualTag_Generation_EquipmentPath",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "UX_VirtualTag_Generation_LogicalId",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "IX_UnsLine_Generation_Area",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "UX_UnsLine_Generation_AreaName",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "UX_UnsLine_Generation_LogicalId",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "IX_UnsArea_Generation_Cluster",
table: "UnsArea");
migrationBuilder.DropIndex(
name: "UX_UnsArea_Generation_ClusterName",
table: "UnsArea");
migrationBuilder.DropIndex(
name: "UX_UnsArea_Generation_LogicalId",
table: "UnsArea");
migrationBuilder.DropIndex(
name: "IX_Tag_Generation_Driver_Device",
table: "Tag");
migrationBuilder.DropIndex(
name: "IX_Tag_Generation_Equipment",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_Generation_EquipmentPath",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_Generation_FolderPath",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_Generation_LogicalId",
table: "Tag");
migrationBuilder.DropIndex(
name: "IX_ScriptedAlarm_Generation_Script",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "UX_ScriptedAlarm_Generation_EquipmentPath",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "UX_ScriptedAlarm_Generation_LogicalId",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "IX_Script_Generation_SourceHash",
table: "Script");
migrationBuilder.DropIndex(
name: "UX_Script_Generation_LogicalId",
table: "Script");
migrationBuilder.DropIndex(
name: "IX_PollGroup_Generation_Driver",
table: "PollGroup");
migrationBuilder.DropIndex(
name: "UX_PollGroup_Generation_LogicalId",
table: "PollGroup");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Generation_Cluster",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Generation_Group",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Generation_Scope",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "UX_NodeAcl_Generation_GroupScope",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "UX_NodeAcl_Generation_LogicalId",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "IX_Namespace_Generation_Cluster",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_Generation_Cluster_Kind",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_Generation_LogicalId",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_Generation_LogicalId_Cluster",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_Generation_NamespaceUri",
table: "Namespace");
migrationBuilder.DropIndex(
name: "IX_Equipment_Generation_Driver",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_Generation_Line",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_Generation_MachineCode",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_Generation_SAPID",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_Generation_ZTag",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_Generation_LinePath",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_Generation_LogicalId",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_Generation_Uuid",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_DriverInstance_Generation_Cluster",
table: "DriverInstance");
migrationBuilder.DropIndex(
name: "IX_DriverInstance_Generation_Namespace",
table: "DriverInstance");
migrationBuilder.DropIndex(
name: "UX_DriverInstance_Generation_LogicalId",
table: "DriverInstance");
migrationBuilder.DropIndex(
name: "IX_Device_Generation_Driver",
table: "Device");
migrationBuilder.DropIndex(
name: "UX_Device_Generation_LogicalId",
table: "Device");
migrationBuilder.DropIndex(
name: "UX_ClusterNode_Primary_Per_Cluster",
table: "ClusterNode");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "VirtualTag");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "UnsLine");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "UnsArea");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "Tag");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "ScriptedAlarm");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "Script");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "PollGroup");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "NodeAcl");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "Namespace");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "Equipment");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "DriverInstance");
migrationBuilder.DropColumn(
name: "GenerationId",
table: "Device");
migrationBuilder.DropColumn(
name: "RedundancyRole",
table: "ClusterNode");
migrationBuilder.RenameIndex(
name: "IX_UnsArea_ClusterId",
table: "UnsArea",
newName: "IX_UnsArea_Cluster");
migrationBuilder.RenameIndex(
name: "IX_Namespace_ClusterId",
table: "Namespace",
newName: "IX_Namespace_Cluster");
migrationBuilder.RenameIndex(
name: "IX_DriverInstance_ClusterId",
table: "DriverInstance",
newName: "IX_DriverInstance_Cluster");
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "VirtualTag",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "UnsLine",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "UnsArea",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Tag",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "ScriptedAlarm",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Script",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "PollGroup",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "NodeAcl",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Namespace",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Equipment",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "DriverInstance",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Device",
type: "rowversion",
rowVersion: true,
nullable: false,
defaultValue: new byte[0]);
migrationBuilder.CreateTable(
name: "ConfigEdit",
columns: table => new
{
EditId = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWSEQUENTIALID()"),
EntityType = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
EntityId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
FieldsJson = table.Column<string>(type: "nvarchar(max)", nullable: false),
ExecutionId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
EditedBy = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
EditedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: false, defaultValueSql: "SYSUTCDATETIME()"),
SourceNode = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConfigEdit", x => x.EditId);
table.CheckConstraint("CK_ConfigEdit_FieldsJson_IsJson", "ISJSON(FieldsJson) = 1");
});
migrationBuilder.CreateTable(
name: "DataProtectionKeys",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FriendlyName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Xml = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DataProtectionKeys", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Deployment",
columns: table => new
{
DeploymentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWSEQUENTIALID()"),
RevisionHash = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
CreatedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: false, defaultValueSql: "SYSUTCDATETIME()"),
ArtifactBlob = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false),
FailureReason = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: true),
SealedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Deployment", x => x.DeploymentId);
});
migrationBuilder.CreateTable(
name: "NodeDeploymentState",
columns: table => new
{
NodeId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
DeploymentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
StartedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: false, defaultValueSql: "SYSUTCDATETIME()"),
AppliedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
FailureReason = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: true),
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NodeDeploymentState", x => new { x.NodeId, x.DeploymentId });
table.ForeignKey(
name: "FK_NodeDeploymentState_ClusterNode_NodeId",
column: x => x.NodeId,
principalTable: "ClusterNode",
principalColumn: "NodeId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_NodeDeploymentState_Deployment_DeploymentId",
column: x => x.DeploymentId,
principalTable: "Deployment",
principalColumn: "DeploymentId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_VirtualTag_Script",
table: "VirtualTag",
column: "ScriptId");
migrationBuilder.CreateIndex(
name: "UX_VirtualTag_EquipmentPath",
table: "VirtualTag",
columns: new[] { "EquipmentId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_VirtualTag_LogicalId",
table: "VirtualTag",
column: "VirtualTagId",
unique: true,
filter: "[VirtualTagId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_UnsLine_Area",
table: "UnsLine",
column: "UnsAreaId");
migrationBuilder.CreateIndex(
name: "UX_UnsLine_AreaName",
table: "UnsLine",
columns: new[] { "UnsAreaId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_UnsLine_LogicalId",
table: "UnsLine",
column: "UnsLineId",
unique: true,
filter: "[UnsLineId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_UnsArea_ClusterName",
table: "UnsArea",
columns: new[] { "ClusterId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_UnsArea_LogicalId",
table: "UnsArea",
column: "UnsAreaId",
unique: true,
filter: "[UnsAreaId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Tag_Driver_Device",
table: "Tag",
columns: new[] { "DriverInstanceId", "DeviceId" });
migrationBuilder.CreateIndex(
name: "IX_Tag_Equipment",
table: "Tag",
column: "EquipmentId",
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_EquipmentPath",
table: "Tag",
columns: new[] { "EquipmentId", "Name" },
unique: true,
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_FolderPath",
table: "Tag",
columns: new[] { "DriverInstanceId", "FolderPath", "Name" },
unique: true,
filter: "[EquipmentId] IS NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_LogicalId",
table: "Tag",
column: "TagId",
unique: true,
filter: "[TagId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_ScriptedAlarm_Script",
table: "ScriptedAlarm",
column: "PredicateScriptId");
migrationBuilder.CreateIndex(
name: "UX_ScriptedAlarm_EquipmentPath",
table: "ScriptedAlarm",
columns: new[] { "EquipmentId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_ScriptedAlarm_LogicalId",
table: "ScriptedAlarm",
column: "ScriptedAlarmId",
unique: true,
filter: "[ScriptedAlarmId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Script_SourceHash",
table: "Script",
column: "SourceHash");
migrationBuilder.CreateIndex(
name: "UX_Script_LogicalId",
table: "Script",
column: "ScriptId",
unique: true,
filter: "[ScriptId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_PollGroup_Driver",
table: "PollGroup",
column: "DriverInstanceId");
migrationBuilder.CreateIndex(
name: "UX_PollGroup_LogicalId",
table: "PollGroup",
column: "PollGroupId",
unique: true,
filter: "[PollGroupId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Cluster",
table: "NodeAcl",
column: "ClusterId");
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Group",
table: "NodeAcl",
column: "LdapGroup");
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Scope",
table: "NodeAcl",
columns: new[] { "ScopeKind", "ScopeId" },
filter: "[ScopeId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_NodeAcl_GroupScope",
table: "NodeAcl",
columns: new[] { "ClusterId", "LdapGroup", "ScopeKind", "ScopeId" },
unique: true,
filter: "[ScopeId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_NodeAcl_LogicalId",
table: "NodeAcl",
column: "NodeAclId",
unique: true,
filter: "[NodeAclId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Namespace_Cluster_Kind",
table: "Namespace",
columns: new[] { "ClusterId", "Kind" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_Namespace_LogicalId",
table: "Namespace",
column: "NamespaceId",
unique: true,
filter: "[NamespaceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Namespace_NamespaceUri",
table: "Namespace",
column: "NamespaceUri",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Equipment_Driver",
table: "Equipment",
column: "DriverInstanceId");
migrationBuilder.CreateIndex(
name: "IX_Equipment_Line",
table: "Equipment",
column: "UnsLineId");
migrationBuilder.CreateIndex(
name: "IX_Equipment_MachineCode",
table: "Equipment",
column: "MachineCode");
migrationBuilder.CreateIndex(
name: "IX_Equipment_SAPID",
table: "Equipment",
column: "SAPID",
filter: "[SAPID] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Equipment_ZTag",
table: "Equipment",
column: "ZTag",
filter: "[ZTag] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Equipment_LinePath",
table: "Equipment",
columns: new[] { "UnsLineId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_Equipment_LogicalId",
table: "Equipment",
column: "EquipmentId",
unique: true,
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Equipment_Uuid",
table: "Equipment",
column: "EquipmentUuid",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DriverInstance_Namespace",
table: "DriverInstance",
column: "NamespaceId");
migrationBuilder.CreateIndex(
name: "UX_DriverInstance_LogicalId",
table: "DriverInstance",
column: "DriverInstanceId",
unique: true,
filter: "[DriverInstanceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Device_Driver",
table: "Device",
column: "DriverInstanceId");
migrationBuilder.CreateIndex(
name: "UX_Device_LogicalId",
table: "Device",
column: "DeviceId",
unique: true,
filter: "[DeviceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_ClusterNode_ClusterId",
table: "ClusterNode",
column: "ClusterId");
migrationBuilder.CreateIndex(
name: "IX_ConfigEdit_EditedAt",
table: "ConfigEdit",
column: "EditedAtUtc");
migrationBuilder.CreateIndex(
name: "IX_ConfigEdit_Entity",
table: "ConfigEdit",
columns: new[] { "EntityType", "EntityId" });
migrationBuilder.CreateIndex(
name: "IX_ConfigEdit_Execution",
table: "ConfigEdit",
column: "ExecutionId",
filter: "[ExecutionId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Deployment_CreatedAt",
table: "Deployment",
column: "CreatedAtUtc");
migrationBuilder.CreateIndex(
name: "IX_Deployment_Status",
table: "Deployment",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_NodeDeploymentState_Deployment",
table: "NodeDeploymentState",
column: "DeploymentId");
migrationBuilder.CreateIndex(
name: "IX_NodeDeploymentState_Status",
table: "NodeDeploymentState",
column: "Status");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ConfigEdit");
migrationBuilder.DropTable(
name: "DataProtectionKeys");
migrationBuilder.DropTable(
name: "NodeDeploymentState");
migrationBuilder.DropTable(
name: "Deployment");
migrationBuilder.DropIndex(
name: "IX_VirtualTag_Script",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "UX_VirtualTag_EquipmentPath",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "UX_VirtualTag_LogicalId",
table: "VirtualTag");
migrationBuilder.DropIndex(
name: "IX_UnsLine_Area",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "UX_UnsLine_AreaName",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "UX_UnsLine_LogicalId",
table: "UnsLine");
migrationBuilder.DropIndex(
name: "UX_UnsArea_ClusterName",
table: "UnsArea");
migrationBuilder.DropIndex(
name: "UX_UnsArea_LogicalId",
table: "UnsArea");
migrationBuilder.DropIndex(
name: "IX_Tag_Driver_Device",
table: "Tag");
migrationBuilder.DropIndex(
name: "IX_Tag_Equipment",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_EquipmentPath",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_FolderPath",
table: "Tag");
migrationBuilder.DropIndex(
name: "UX_Tag_LogicalId",
table: "Tag");
migrationBuilder.DropIndex(
name: "IX_ScriptedAlarm_Script",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "UX_ScriptedAlarm_EquipmentPath",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "UX_ScriptedAlarm_LogicalId",
table: "ScriptedAlarm");
migrationBuilder.DropIndex(
name: "IX_Script_SourceHash",
table: "Script");
migrationBuilder.DropIndex(
name: "UX_Script_LogicalId",
table: "Script");
migrationBuilder.DropIndex(
name: "IX_PollGroup_Driver",
table: "PollGroup");
migrationBuilder.DropIndex(
name: "UX_PollGroup_LogicalId",
table: "PollGroup");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Cluster",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Group",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "IX_NodeAcl_Scope",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "UX_NodeAcl_GroupScope",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "UX_NodeAcl_LogicalId",
table: "NodeAcl");
migrationBuilder.DropIndex(
name: "UX_Namespace_Cluster_Kind",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_LogicalId",
table: "Namespace");
migrationBuilder.DropIndex(
name: "UX_Namespace_NamespaceUri",
table: "Namespace");
migrationBuilder.DropIndex(
name: "IX_Equipment_Driver",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_Line",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_MachineCode",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_SAPID",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Equipment_ZTag",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_LinePath",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_LogicalId",
table: "Equipment");
migrationBuilder.DropIndex(
name: "UX_Equipment_Uuid",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_DriverInstance_Namespace",
table: "DriverInstance");
migrationBuilder.DropIndex(
name: "UX_DriverInstance_LogicalId",
table: "DriverInstance");
migrationBuilder.DropIndex(
name: "IX_Device_Driver",
table: "Device");
migrationBuilder.DropIndex(
name: "UX_Device_LogicalId",
table: "Device");
migrationBuilder.DropIndex(
name: "IX_ClusterNode_ClusterId",
table: "ClusterNode");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "VirtualTag");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "UnsLine");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "UnsArea");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Tag");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "ScriptedAlarm");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Script");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "PollGroup");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "NodeAcl");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Namespace");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Equipment");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "DriverInstance");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Device");
migrationBuilder.RenameIndex(
name: "IX_UnsArea_Cluster",
table: "UnsArea",
newName: "IX_UnsArea_ClusterId");
migrationBuilder.RenameIndex(
name: "IX_Namespace_Cluster",
table: "Namespace",
newName: "IX_Namespace_ClusterId");
migrationBuilder.RenameIndex(
name: "IX_DriverInstance_Cluster",
table: "DriverInstance",
newName: "IX_DriverInstance_ClusterId");
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "VirtualTag",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "UnsLine",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "UnsArea",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "Tag",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "ScriptedAlarm",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "Script",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "PollGroup",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "NodeAcl",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "Namespace",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "Equipment",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "DriverInstance",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "GenerationId",
table: "Device",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<string>(
name: "RedundancyRole",
table: "ClusterNode",
type: "nvarchar(16)",
maxLength: 16,
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "ConfigGeneration",
columns: table => new
{
GenerationId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClusterId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
ParentGenerationId = table.Column<long>(type: "bigint", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2(3)", nullable: false, defaultValueSql: "SYSUTCDATETIME()"),
CreatedBy = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Notes = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
PublishedAt = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
PublishedBy = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
Status = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConfigGeneration", x => x.GenerationId);
table.ForeignKey(
name: "FK_ConfigGeneration_ConfigGeneration_ParentGenerationId",
column: x => x.ParentGenerationId,
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ConfigGeneration_ServerCluster_ClusterId",
column: x => x.ClusterId,
principalTable: "ServerCluster",
principalColumn: "ClusterId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ClusterNodeGenerationState",
columns: table => new
{
NodeId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
CurrentGenerationId = table.Column<long>(type: "bigint", nullable: true),
LastAppliedAt = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
LastAppliedError = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: true),
LastAppliedStatus = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
LastSeenAt = table.Column<DateTime>(type: "datetime2(3)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClusterNodeGenerationState", x => x.NodeId);
table.ForeignKey(
name: "FK_ClusterNodeGenerationState_ClusterNode_NodeId",
column: x => x.NodeId,
principalTable: "ClusterNode",
principalColumn: "NodeId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ClusterNodeGenerationState_ConfigGeneration_CurrentGenerationId",
column: x => x.CurrentGenerationId,
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_VirtualTag_Generation_Script",
table: "VirtualTag",
columns: new[] { "GenerationId", "ScriptId" });
migrationBuilder.CreateIndex(
name: "UX_VirtualTag_Generation_EquipmentPath",
table: "VirtualTag",
columns: new[] { "GenerationId", "EquipmentId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_VirtualTag_Generation_LogicalId",
table: "VirtualTag",
columns: new[] { "GenerationId", "VirtualTagId" },
unique: true,
filter: "[VirtualTagId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_UnsLine_Generation_Area",
table: "UnsLine",
columns: new[] { "GenerationId", "UnsAreaId" });
migrationBuilder.CreateIndex(
name: "UX_UnsLine_Generation_AreaName",
table: "UnsLine",
columns: new[] { "GenerationId", "UnsAreaId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_UnsLine_Generation_LogicalId",
table: "UnsLine",
columns: new[] { "GenerationId", "UnsLineId" },
unique: true,
filter: "[UnsLineId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_UnsArea_Generation_Cluster",
table: "UnsArea",
columns: new[] { "GenerationId", "ClusterId" });
migrationBuilder.CreateIndex(
name: "UX_UnsArea_Generation_ClusterName",
table: "UnsArea",
columns: new[] { "GenerationId", "ClusterId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_UnsArea_Generation_LogicalId",
table: "UnsArea",
columns: new[] { "GenerationId", "UnsAreaId" },
unique: true,
filter: "[UnsAreaId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Tag_Generation_Driver_Device",
table: "Tag",
columns: new[] { "GenerationId", "DriverInstanceId", "DeviceId" });
migrationBuilder.CreateIndex(
name: "IX_Tag_Generation_Equipment",
table: "Tag",
columns: new[] { "GenerationId", "EquipmentId" },
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_Generation_EquipmentPath",
table: "Tag",
columns: new[] { "GenerationId", "EquipmentId", "Name" },
unique: true,
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_Generation_FolderPath",
table: "Tag",
columns: new[] { "GenerationId", "DriverInstanceId", "FolderPath", "Name" },
unique: true,
filter: "[EquipmentId] IS NULL");
migrationBuilder.CreateIndex(
name: "UX_Tag_Generation_LogicalId",
table: "Tag",
columns: new[] { "GenerationId", "TagId" },
unique: true,
filter: "[TagId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_ScriptedAlarm_Generation_Script",
table: "ScriptedAlarm",
columns: new[] { "GenerationId", "PredicateScriptId" });
migrationBuilder.CreateIndex(
name: "UX_ScriptedAlarm_Generation_EquipmentPath",
table: "ScriptedAlarm",
columns: new[] { "GenerationId", "EquipmentId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_ScriptedAlarm_Generation_LogicalId",
table: "ScriptedAlarm",
columns: new[] { "GenerationId", "ScriptedAlarmId" },
unique: true,
filter: "[ScriptedAlarmId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Script_Generation_SourceHash",
table: "Script",
columns: new[] { "GenerationId", "SourceHash" });
migrationBuilder.CreateIndex(
name: "UX_Script_Generation_LogicalId",
table: "Script",
columns: new[] { "GenerationId", "ScriptId" },
unique: true,
filter: "[ScriptId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_PollGroup_Generation_Driver",
table: "PollGroup",
columns: new[] { "GenerationId", "DriverInstanceId" });
migrationBuilder.CreateIndex(
name: "UX_PollGroup_Generation_LogicalId",
table: "PollGroup",
columns: new[] { "GenerationId", "PollGroupId" },
unique: true,
filter: "[PollGroupId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Generation_Cluster",
table: "NodeAcl",
columns: new[] { "GenerationId", "ClusterId" });
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Generation_Group",
table: "NodeAcl",
columns: new[] { "GenerationId", "LdapGroup" });
migrationBuilder.CreateIndex(
name: "IX_NodeAcl_Generation_Scope",
table: "NodeAcl",
columns: new[] { "GenerationId", "ScopeKind", "ScopeId" },
filter: "[ScopeId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_NodeAcl_Generation_GroupScope",
table: "NodeAcl",
columns: new[] { "GenerationId", "ClusterId", "LdapGroup", "ScopeKind", "ScopeId" },
unique: true,
filter: "[ScopeId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_NodeAcl_Generation_LogicalId",
table: "NodeAcl",
columns: new[] { "GenerationId", "NodeAclId" },
unique: true,
filter: "[NodeAclId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Namespace_Generation_Cluster",
table: "Namespace",
columns: new[] { "GenerationId", "ClusterId" });
migrationBuilder.CreateIndex(
name: "UX_Namespace_Generation_Cluster_Kind",
table: "Namespace",
columns: new[] { "GenerationId", "ClusterId", "Kind" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_Namespace_Generation_LogicalId",
table: "Namespace",
columns: new[] { "GenerationId", "NamespaceId" },
unique: true,
filter: "[NamespaceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Namespace_Generation_LogicalId_Cluster",
table: "Namespace",
columns: new[] { "GenerationId", "NamespaceId", "ClusterId" },
unique: true,
filter: "[NamespaceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Namespace_Generation_NamespaceUri",
table: "Namespace",
columns: new[] { "GenerationId", "NamespaceUri" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Equipment_Generation_Driver",
table: "Equipment",
columns: new[] { "GenerationId", "DriverInstanceId" });
migrationBuilder.CreateIndex(
name: "IX_Equipment_Generation_Line",
table: "Equipment",
columns: new[] { "GenerationId", "UnsLineId" });
migrationBuilder.CreateIndex(
name: "IX_Equipment_Generation_MachineCode",
table: "Equipment",
columns: new[] { "GenerationId", "MachineCode" });
migrationBuilder.CreateIndex(
name: "IX_Equipment_Generation_SAPID",
table: "Equipment",
columns: new[] { "GenerationId", "SAPID" },
filter: "[SAPID] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Equipment_Generation_ZTag",
table: "Equipment",
columns: new[] { "GenerationId", "ZTag" },
filter: "[ZTag] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Equipment_Generation_LinePath",
table: "Equipment",
columns: new[] { "GenerationId", "UnsLineId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_Equipment_Generation_LogicalId",
table: "Equipment",
columns: new[] { "GenerationId", "EquipmentId" },
unique: true,
filter: "[EquipmentId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_Equipment_Generation_Uuid",
table: "Equipment",
columns: new[] { "GenerationId", "EquipmentUuid" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DriverInstance_Generation_Cluster",
table: "DriverInstance",
columns: new[] { "GenerationId", "ClusterId" });
migrationBuilder.CreateIndex(
name: "IX_DriverInstance_Generation_Namespace",
table: "DriverInstance",
columns: new[] { "GenerationId", "NamespaceId" });
migrationBuilder.CreateIndex(
name: "UX_DriverInstance_Generation_LogicalId",
table: "DriverInstance",
columns: new[] { "GenerationId", "DriverInstanceId" },
unique: true,
filter: "[DriverInstanceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Device_Generation_Driver",
table: "Device",
columns: new[] { "GenerationId", "DriverInstanceId" });
migrationBuilder.CreateIndex(
name: "UX_Device_Generation_LogicalId",
table: "Device",
columns: new[] { "GenerationId", "DeviceId" },
unique: true,
filter: "[DeviceId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "UX_ClusterNode_Primary_Per_Cluster",
table: "ClusterNode",
column: "ClusterId",
unique: true,
filter: "[RedundancyRole] = 'Primary'");
migrationBuilder.CreateIndex(
name: "IX_ClusterNodeGenerationState_Generation",
table: "ClusterNodeGenerationState",
column: "CurrentGenerationId");
migrationBuilder.CreateIndex(
name: "IX_ConfigGeneration_Cluster_Published",
table: "ConfigGeneration",
columns: new[] { "ClusterId", "Status", "GenerationId" },
descending: new[] { false, false, true })
.Annotation("SqlServer:Include", new[] { "PublishedAt" });
migrationBuilder.CreateIndex(
name: "IX_ConfigGeneration_ParentGenerationId",
table: "ConfigGeneration",
column: "ParentGenerationId");
migrationBuilder.CreateIndex(
name: "UX_ConfigGeneration_Draft_Per_Cluster",
table: "ConfigGeneration",
column: "ClusterId",
unique: true,
filter: "[Status] = 'Draft'");
migrationBuilder.AddForeignKey(
name: "FK_Device_ConfigGeneration_GenerationId",
table: "Device",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_DriverInstance_ConfigGeneration_GenerationId",
table: "DriverInstance",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Equipment_ConfigGeneration_GenerationId",
table: "Equipment",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Namespace_ConfigGeneration_GenerationId",
table: "Namespace",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_NodeAcl_ConfigGeneration_GenerationId",
table: "NodeAcl",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PollGroup_ConfigGeneration_GenerationId",
table: "PollGroup",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Script_ConfigGeneration_GenerationId",
table: "Script",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ScriptedAlarm_ConfigGeneration_GenerationId",
table: "ScriptedAlarm",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Tag_ConfigGeneration_GenerationId",
table: "Tag",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UnsArea_ConfigGeneration_GenerationId",
table: "UnsArea",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UnsLine_ConfigGeneration_GenerationId",
table: "UnsLine",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_VirtualTag_ConfigGeneration_GenerationId",
table: "VirtualTag",
column: "GenerationId",
principalTable: "ConfigGeneration",
principalColumn: "GenerationId",
onDelete: ReferentialAction.Restrict);
}
}
}