deploy(prod): PROD ScadaBridge SQL checked (wwpdsbrw read/write, no DDL); DBA-built DB lacks 104 indexes, history, seed rows; completion script

Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
This commit is contained in:
Joseph Doherty
2026-11-20 13:59:23 -05:00
parent e17474c80d
commit d88e820a1c
4 changed files with 363 additions and 3 deletions
@@ -0,0 +1,48 @@
# 2026-11-20: PROD ScadaBridge SQL check (`wondersqlpd` / `ScadaBridge`)
**Owner request:** "prod scadabridge db info in the scadabridge prod.txt. test them, verify it has tables populated or you can
make a new table". Connection details: owner file `~/Desktop/ScadaBridge/prod.txt` (untracked; holds a plaintext password,
never commit it). Direct SQL from the Mac (sqlcmd / pymssql, password by env only); no WinRM, no box touched.
## Connection
- `wondersqlpd.zmr.zimmer.com` → `@@SERVERNAME` `WONDER-SQL-VP03`, SQL Server 2022 RTM-CU16 Enterprise (16.0.4165.4).
- DB `ScadaBridge`: compat 160, `SQL_Latin1_General_CP1_CI_AS`, FULL recovery, RCSI/snapshot off (QA has the same settings).
- Login `wwpdsbrw` (SQL auth): `db_datareader` + `db_datawriter`, not `db_owner`/`db_ddladmin`/sysadmin, no VIEW DEFINITION.
Write test inside rolled-back transactions: `CREATE TABLE` **denied**; INSERT/SELECT/UPDATE/DELETE on
`dbo.DataProtectionKeys` **ok**, 0 rows left behind, no test table left.
## Contents vs QA (`wonder-sql-vq03.ScadaBridge`, same build 2e0ce81e, 65 migrations)
Schema fingerprint diff (columns, indexes, FKs, checks, modules, schemas, sequences):
| Item | QA | PROD |
|---|---|---|
| Tables (dbo / zbauth / zbsecrets) | 41 / 3 / 2 | 41 / 3 / 2, all created 2026-11-20 09:37:50 (AuditLog 09:51:25) |
| Columns (name, type, length, null, identity) | 370 | 370, same; computed (6) and default (16) counts match; their definitions are hidden from this login |
| PKs / FKs | 46 / 27 | 46 / 27, same |
| AuditLog partitioning | `pf/ps_AuditLog_Month`, 25 partitions | same |
| **Nonclustered / unique indexes** | **104** | **0** (sys.indexes and sys.partitions both) |
| **`__EFMigrationsHistory`** | **65 rows, last `20261115221558_RemoveAuditLogHashChain`** | **0 rows** |
| **`zbauth` / `zbsecrets` `schema_version`** | 1 row each (v1) | **0 rows**; 2 check constraints each (QA has 1) |
| **`LdapGroupMappings` seed ids 1–5** | present | **0 rows** |
| Data rows | — | every table empty |
So a DBA built the tables (not from our script, which writes the history), but without the indexes or seed/history rows.
## Effect if started as is
- Central (Production): `MigrationHelper` throws "65 pending migration(s)" → no start.
- `zbauth` migrator: its guarded `CREATE INDEX ix_api_keys_revoked_utc` runs and is denied for `wwpdsbrw` → no start.
- Missing unique indexes (e.g. `IX_Sites_Name`, `IX_Instances_UniqueName`, `UX_AuditLog_EventId_Occurred`) would also drop
uniqueness the app relies on.
## Fix (for a DBA; `wwpdsbrw` cannot)
`sql/prod-complete-dba-schema.sql` (sha256 `17e0e7d6bb6707b140f07b94c1969563e49bd41ca541275595c36971bc037a65`), generated
from QA's metadata: 104 guarded `CREATE [UNIQUE] NONCLUSTERED INDEX` (AuditLog ones on `ps_AuditLog_Month(OccurredAtUtc)`),
QA's 65 history rows, both `schema_version` v1 rows, and the 5 seed mappings. One transaction, idempotent, refuses a
different migration state. Compiled against PROD under `SET NOEXEC ON` (names bind; nothing ran; history still 0).
After it runs: re-run the schema diff → 0 index differences; then `sb-role-mappings-prod.sql` (DML, the app login can).
Not run: nothing was written to PROD outside the rolled-back test transactions.
@@ -55,6 +55,9 @@ greenfield box.
- **SQL (centrals, `sql\`)**: `scadabridge-schema-2e0ce81e.sql` (full, non-idempotent, 65 migrations, from `dotnet ef
migrations script 0 20261115221558_RemoveAuditLogHashChain` at 2e0ce81e; run with `sqlcmd -I -b`),
`zbsecrets-schema-v1.sql`, `sb-role-mappings-prod.sql` (the five `_PROD` rows, D-P6).
**2026-11-20:** the PROD DB (`wondersqlpd`, login `wwpdsbrw`, no DDL) was pre-built by a DBA without indexes, history,
`schema_version` or seed rows. Use `prod-complete-dba-schema.sql` (DBA) instead of the schema script; see
[`2026-11-20-prod-sql-check.md`](2026-11-20-prod-sql-check.md).
### Placeholders still open (the install scripts refuse while any remains)
@@ -0,0 +1,309 @@
-- ScadaBridge PROD (wondersqlpd / ScadaBridge): complete the DBA-built 2e0ce81e schema.
-- Generated 2026-11-20 from QA wonder-sql-vq03.ScadaBridge (same build, all 65 migrations applied).
-- The DBA build has every table, PK, FK, default, computed column and the AuditLog partition scheme,
-- but none of the 104 nonclustered indexes, no __EFMigrationsHistory rows, no schema_version rows and no seed rows
-- (LdapGroupMappings ids 1-5). All tables were empty at 2026-11-20 checks.
-- Run as a principal with ALTER/CREATE INDEX rights (db_owner or db_ddladmin); the app login wwpdsbrw cannot.
-- Idempotent: every statement is guarded. Run with: sqlcmd -S wondersqlpd.zmr.zimmer.com -d ScadaBridge -C -b -I -i <this file>
SET XACT_ABORT ON; SET NOCOUNT ON;
IF DB_NAME() <> N'ScadaBridge' BEGIN RAISERROR('wrong database',16,1); RETURN; END
IF EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory) AND NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261115221558_RemoveAuditLogHashChain')
BEGIN RAISERROR('history present but not at 2e0ce81e - stop',16,1); RETURN; END
BEGIN TRAN;
-- 1. 104 nonclustered indexes
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ApiMethods]') AND name = N'IX_ApiMethods_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ApiMethods_Name] ON [dbo].[ApiMethods] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Areas]') AND name = N'IX_Areas_ParentAreaId')
CREATE NONCLUSTERED INDEX [IX_Areas_ParentAreaId] ON [dbo].[Areas] ([ParentAreaId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Areas]') AND name = N'IX_Areas_SiteId_ParentAreaId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Areas_SiteId_ParentAreaId_Name] ON [dbo].[Areas] ([SiteId], [ParentAreaId], [Name]) WHERE ([ParentAreaId] IS NOT NULL);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Actor_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Actor_Occurred] ON [dbo].[AuditLog] ([Actor], [OccurredAtUtc] DESC) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Channel_Status_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Channel_Status_Occurred] ON [dbo].[AuditLog] ([Category], [Status], [OccurredAtUtc] DESC) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_CorrelationId')
CREATE NONCLUSTERED INDEX [IX_AuditLog_CorrelationId] ON [dbo].[AuditLog] ([CorrelationId]) WHERE ([CorrelationId] IS NOT NULL) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Execution')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Execution] ON [dbo].[AuditLog] ([ExecutionId]) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Kind_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Kind_Occurred] ON [dbo].[AuditLog] ([Kind], [OccurredAtUtc] DESC) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Node_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Node_Occurred] ON [dbo].[AuditLog] ([SourceNode], [OccurredAtUtc]) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_OccurredAtUtc')
CREATE NONCLUSTERED INDEX [IX_AuditLog_OccurredAtUtc] ON [dbo].[AuditLog] ([OccurredAtUtc] DESC) INCLUDE ([Status]) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_ParentExecution')
CREATE NONCLUSTERED INDEX [IX_AuditLog_ParentExecution] ON [dbo].[AuditLog] ([ParentExecutionId]) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Site_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Site_Occurred] ON [dbo].[AuditLog] ([SourceSiteId], [OccurredAtUtc] DESC) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'IX_AuditLog_Target_Occurred')
CREATE NONCLUSTERED INDEX [IX_AuditLog_Target_Occurred] ON [dbo].[AuditLog] ([Target], [OccurredAtUtc] DESC) WHERE ([Target] IS NOT NULL) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLog]') AND name = N'UX_AuditLog_EventId_Occurred')
CREATE UNIQUE NONCLUSTERED INDEX [UX_AuditLog_EventId_Occurred] ON [dbo].[AuditLog] ([EventId], [OccurredAtUtc]) ON [ps_AuditLog_Month]([OccurredAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_Action')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_Action] ON [dbo].[AuditLogEntries] ([Action]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_BundleImportId')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_BundleImportId] ON [dbo].[AuditLogEntries] ([BundleImportId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_EntityId')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_EntityId] ON [dbo].[AuditLogEntries] ([EntityId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_EntityName')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_EntityName] ON [dbo].[AuditLogEntries] ([EntityName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_EntityType')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_EntityType] ON [dbo].[AuditLogEntries] ([EntityType]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_EntityType_Timestamp')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_EntityType_Timestamp] ON [dbo].[AuditLogEntries] ([EntityType], [Timestamp] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_Timestamp')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_Timestamp] ON [dbo].[AuditLogEntries] ([Timestamp]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_Timestamp_Id')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_Timestamp_Id] ON [dbo].[AuditLogEntries] ([Timestamp] DESC, [Id] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_User')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_User] ON [dbo].[AuditLogEntries] ([User]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[AuditLogEntries]') AND name = N'IX_AuditLogEntries_User_Timestamp')
CREATE NONCLUSTERED INDEX [IX_AuditLogEntries_User_Timestamp] ON [dbo].[AuditLogEntries] ([User], [Timestamp] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BundleUnlockAttempt]') AND name = N'IX_BundleUnlockAttempt_Client_Attempted')
CREATE NONCLUSTERED INDEX [IX_BundleUnlockAttempt_Client_Attempted] ON [dbo].[BundleUnlockAttempt] ([ClientKey], [AttemptedAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DatabaseConnectionDefinitions]') AND name = N'IX_DatabaseConnectionDefinitions_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_DatabaseConnectionDefinitions_Name] ON [dbo].[DatabaseConnectionDefinitions] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DatabaseConnectionDefinitions]') AND name = N'IX_DatabaseConnectionDefinitions_RowVersion')
CREATE NONCLUSTERED INDEX [IX_DatabaseConnectionDefinitions_RowVersion] ON [dbo].[DatabaseConnectionDefinitions] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DataConnections]') AND name = N'IX_DataConnections_RowVersion')
CREATE NONCLUSTERED INDEX [IX_DataConnections_RowVersion] ON [dbo].[DataConnections] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DataConnections]') AND name = N'IX_DataConnections_SiteId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_DataConnections_SiteId_Name] ON [dbo].[DataConnections] ([SiteId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeployedConfigSnapshots]') AND name = N'IX_DeployedConfigSnapshots_DeploymentId')
CREATE NONCLUSTERED INDEX [IX_DeployedConfigSnapshots_DeploymentId] ON [dbo].[DeployedConfigSnapshots] ([DeploymentId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeployedConfigSnapshots]') AND name = N'IX_DeployedConfigSnapshots_InstanceId')
CREATE UNIQUE NONCLUSTERED INDEX [IX_DeployedConfigSnapshots_InstanceId] ON [dbo].[DeployedConfigSnapshots] ([InstanceId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeployedConfigSnapshots]') AND name = N'IX_DeployedConfigSnapshots_RowVersion')
CREATE NONCLUSTERED INDEX [IX_DeployedConfigSnapshots_RowVersion] ON [dbo].[DeployedConfigSnapshots] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentRecords]') AND name = N'IX_DeploymentRecords_DeployedAt_Id')
CREATE NONCLUSTERED INDEX [IX_DeploymentRecords_DeployedAt_Id] ON [dbo].[DeploymentRecords] ([DeployedAt] DESC, [Id] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentRecords]') AND name = N'IX_DeploymentRecords_DeployedBy')
CREATE NONCLUSTERED INDEX [IX_DeploymentRecords_DeployedBy] ON [dbo].[DeploymentRecords] ([DeployedBy]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentRecords]') AND name = N'IX_DeploymentRecords_DeploymentId')
CREATE UNIQUE NONCLUSTERED INDEX [IX_DeploymentRecords_DeploymentId] ON [dbo].[DeploymentRecords] ([DeploymentId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentRecords]') AND name = N'IX_DeploymentRecords_InstanceId')
CREATE NONCLUSTERED INDEX [IX_DeploymentRecords_InstanceId] ON [dbo].[DeploymentRecords] ([InstanceId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentRecords]') AND name = N'IX_DeploymentRecords_RevisionHash')
CREATE NONCLUSTERED INDEX [IX_DeploymentRecords_RevisionHash] ON [dbo].[DeploymentRecords] ([RevisionHash]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ExternalSystemDefinitions]') AND name = N'IX_ExternalSystemDefinitions_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ExternalSystemDefinitions_Name] ON [dbo].[ExternalSystemDefinitions] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ExternalSystemDefinitions]') AND name = N'IX_ExternalSystemDefinitions_RowVersion')
CREATE NONCLUSTERED INDEX [IX_ExternalSystemDefinitions_RowVersion] ON [dbo].[ExternalSystemDefinitions] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ExternalSystemMethods]') AND name = N'IX_ExternalSystemMethods_ExternalSystemDefinitionId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ExternalSystemMethods_ExternalSystemDefinitionId_Name] ON [dbo].[ExternalSystemMethods] ([ExternalSystemDefinitionId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ExternalSystemMethods]') AND name = N'IX_ExternalSystemMethods_RowVersion')
CREATE NONCLUSTERED INDEX [IX_ExternalSystemMethods_RowVersion] ON [dbo].[ExternalSystemMethods] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceAlarmOverrides]') AND name = N'IX_InstanceAlarmOverrides_InstanceId_AlarmCanonicalName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_InstanceAlarmOverrides_InstanceId_AlarmCanonicalName] ON [dbo].[InstanceAlarmOverrides] ([InstanceId], [AlarmCanonicalName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceAlarmOverrides]') AND name = N'IX_InstanceAlarmOverrides_RowVersion')
CREATE NONCLUSTERED INDEX [IX_InstanceAlarmOverrides_RowVersion] ON [dbo].[InstanceAlarmOverrides] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceAttributeOverrides]') AND name = N'IX_InstanceAttributeOverrides_InstanceId_AttributeName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_InstanceAttributeOverrides_InstanceId_AttributeName] ON [dbo].[InstanceAttributeOverrides] ([InstanceId], [AttributeName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceAttributeOverrides]') AND name = N'IX_InstanceAttributeOverrides_RowVersion')
CREATE NONCLUSTERED INDEX [IX_InstanceAttributeOverrides_RowVersion] ON [dbo].[InstanceAttributeOverrides] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceConnectionBindings]') AND name = N'IX_InstanceConnectionBindings_DataConnectionId')
CREATE NONCLUSTERED INDEX [IX_InstanceConnectionBindings_DataConnectionId] ON [dbo].[InstanceConnectionBindings] ([DataConnectionId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceConnectionBindings]') AND name = N'IX_InstanceConnectionBindings_InstanceId_AttributeName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_InstanceConnectionBindings_InstanceId_AttributeName] ON [dbo].[InstanceConnectionBindings] ([InstanceId], [AttributeName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceConnectionBindings]') AND name = N'IX_InstanceConnectionBindings_RowVersion')
CREATE NONCLUSTERED INDEX [IX_InstanceConnectionBindings_RowVersion] ON [dbo].[InstanceConnectionBindings] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceNativeAlarmSourceOverrides]') AND name = N'IX_InstanceNativeAlarmSourceOverrides_InstanceId_SourceCanonicalName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_InstanceNativeAlarmSourceOverrides_InstanceId_SourceCanonicalName] ON [dbo].[InstanceNativeAlarmSourceOverrides] ([InstanceId], [SourceCanonicalName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[InstanceNativeAlarmSourceOverrides]') AND name = N'IX_InstanceNativeAlarmSourceOverrides_RowVersion')
CREATE NONCLUSTERED INDEX [IX_InstanceNativeAlarmSourceOverrides_RowVersion] ON [dbo].[InstanceNativeAlarmSourceOverrides] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Instances]') AND name = N'IX_Instances_AreaId')
CREATE NONCLUSTERED INDEX [IX_Instances_AreaId] ON [dbo].[Instances] ([AreaId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Instances]') AND name = N'IX_Instances_RowVersion')
CREATE NONCLUSTERED INDEX [IX_Instances_RowVersion] ON [dbo].[Instances] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Instances]') AND name = N'IX_Instances_SiteId')
CREATE NONCLUSTERED INDEX [IX_Instances_SiteId] ON [dbo].[Instances] ([SiteId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Instances]') AND name = N'IX_Instances_TemplateId')
CREATE NONCLUSTERED INDEX [IX_Instances_TemplateId] ON [dbo].[Instances] ([TemplateId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Instances]') AND name = N'IX_Instances_UniqueName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Instances_UniqueName] ON [dbo].[Instances] ([UniqueName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[KpiRollupHourly]') AND name = N'IX_KpiRollupHourly_Hour')
CREATE NONCLUSTERED INDEX [IX_KpiRollupHourly_Hour] ON [dbo].[KpiRollupHourly] ([HourStartUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[KpiRollupHourly]') AND name = N'IX_KpiRollupHourly_Series')
CREATE UNIQUE NONCLUSTERED INDEX [IX_KpiRollupHourly_Series] ON [dbo].[KpiRollupHourly] ([Source], [Metric], [Scope], [ScopeKey], [HourStartUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[KpiSample]') AND name = N'IX_KpiSample_Captured')
CREATE NONCLUSTERED INDEX [IX_KpiSample_Captured] ON [dbo].[KpiSample] ([CapturedAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[KpiSample]') AND name = N'IX_KpiSample_Series')
CREATE NONCLUSTERED INDEX [IX_KpiSample_Series] ON [dbo].[KpiSample] ([Source], [Metric], [Scope], [ScopeKey], [CapturedAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LdapGroupMappings]') AND name = N'IX_LdapGroupMappings_LdapGroupName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_LdapGroupMappings_LdapGroupName] ON [dbo].[LdapGroupMappings] ([LdapGroupName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[NotificationLists]') AND name = N'IX_NotificationLists_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_NotificationLists_Name] ON [dbo].[NotificationLists] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[NotificationRecipients]') AND name = N'IX_NotificationRecipients_NotificationListId')
CREATE NONCLUSTERED INDEX [IX_NotificationRecipients_NotificationListId] ON [dbo].[NotificationRecipients] ([NotificationListId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Notifications]') AND name = N'IX_Notifications_Created_NotificationId')
CREATE NONCLUSTERED INDEX [IX_Notifications_Created_NotificationId] ON [dbo].[Notifications] ([CreatedAt] DESC, [NotificationId] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Notifications]') AND name = N'IX_Notifications_Delivered')
CREATE NONCLUSTERED INDEX [IX_Notifications_Delivered] ON [dbo].[Notifications] ([DeliveredAt]) WHERE ([Status]='Delivered');
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Notifications]') AND name = N'IX_Notifications_SourceSiteId_CreatedAt')
CREATE NONCLUSTERED INDEX [IX_Notifications_SourceSiteId_CreatedAt] ON [dbo].[Notifications] ([SourceSiteId], [CreatedAt]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Notifications]') AND name = N'IX_Notifications_Status_NextAttemptAt')
CREATE NONCLUSTERED INDEX [IX_Notifications_Status_NextAttemptAt] ON [dbo].[Notifications] ([Status], [NextAttemptAt]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PendingDeployments]') AND name = N'IX_PendingDeployments_DeploymentId')
CREATE UNIQUE NONCLUSTERED INDEX [IX_PendingDeployments_DeploymentId] ON [dbo].[PendingDeployments] ([DeploymentId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PendingDeployments]') AND name = N'IX_PendingDeployments_ExpiresAtUtc')
CREATE NONCLUSTERED INDEX [IX_PendingDeployments_ExpiresAtUtc] ON [dbo].[PendingDeployments] ([ExpiresAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PendingDeployments]') AND name = N'IX_PendingDeployments_InstanceId')
CREATE NONCLUSTERED INDEX [IX_PendingDeployments_InstanceId] ON [dbo].[PendingDeployments] ([InstanceId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PendingSecuredWrites]') AND name = N'IX_PendingSecuredWrites_Site')
CREATE NONCLUSTERED INDEX [IX_PendingSecuredWrites_Site] ON [dbo].[PendingSecuredWrites] ([SiteId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PendingSecuredWrites]') AND name = N'IX_PendingSecuredWrites_Status_Submitted')
CREATE NONCLUSTERED INDEX [IX_PendingSecuredWrites_Status_Submitted] ON [dbo].[PendingSecuredWrites] ([Status], [SubmittedAtUtc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SharedSchemas]') AND name = N'IX_SharedSchemas_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_SharedSchemas_Name] ON [dbo].[SharedSchemas] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SharedScripts]') AND name = N'IX_SharedScripts_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_SharedScripts_Name] ON [dbo].[SharedScripts] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SharedScripts]') AND name = N'IX_SharedScripts_RowVersion')
CREATE NONCLUSTERED INDEX [IX_SharedScripts_RowVersion] ON [dbo].[SharedScripts] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteCalls]') AND name = N'IX_SiteCalls_Created_TrackedOperationId')
CREATE NONCLUSTERED INDEX [IX_SiteCalls_Created_TrackedOperationId] ON [dbo].[SiteCalls] ([CreatedAtUtc] DESC, [TrackedOperationId] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteCalls]') AND name = N'IX_SiteCalls_NonTerminal')
CREATE NONCLUSTERED INDEX [IX_SiteCalls_NonTerminal] ON [dbo].[SiteCalls] ([CreatedAtUtc]) INCLUDE ([SourceSite], [SourceNode], [Status]) WHERE ([TerminalAtUtc] IS NULL);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteCalls]') AND name = N'IX_SiteCalls_Source_Created')
CREATE NONCLUSTERED INDEX [IX_SiteCalls_Source_Created] ON [dbo].[SiteCalls] ([SourceSite], [CreatedAtUtc] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteCalls]') AND name = N'IX_SiteCalls_Status_Updated')
CREATE NONCLUSTERED INDEX [IX_SiteCalls_Status_Updated] ON [dbo].[SiteCalls] ([Status], [UpdatedAtUtc] DESC);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteCalls]') AND name = N'IX_SiteCalls_Terminal')
CREATE NONCLUSTERED INDEX [IX_SiteCalls_Terminal] ON [dbo].[SiteCalls] ([TerminalAtUtc]) WHERE ([TerminalAtUtc] IS NOT NULL);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Sites]') AND name = N'IX_Sites_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Sites_Name] ON [dbo].[Sites] ([Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Sites]') AND name = N'IX_Sites_RowVersion')
CREATE NONCLUSTERED INDEX [IX_Sites_RowVersion] ON [dbo].[Sites] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Sites]') AND name = N'IX_Sites_SiteIdentifier')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Sites_SiteIdentifier] ON [dbo].[Sites] ([SiteIdentifier]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteScopeRules]') AND name = N'IX_SiteScopeRules_LdapGroupMappingId_SiteId')
CREATE UNIQUE NONCLUSTERED INDEX [IX_SiteScopeRules_LdapGroupMappingId_SiteId] ON [dbo].[SiteScopeRules] ([LdapGroupMappingId], [SiteId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SiteScopeRules]') AND name = N'IX_SiteScopeRules_SiteId')
CREATE NONCLUSTERED INDEX [IX_SiteScopeRules_SiteId] ON [dbo].[SiteScopeRules] ([SiteId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[SystemArtifactDeploymentRecords]') AND name = N'IX_SystemArtifactDeploymentRecords_DeployedAt')
CREATE NONCLUSTERED INDEX [IX_SystemArtifactDeploymentRecords_DeployedAt] ON [dbo].[SystemArtifactDeploymentRecords] ([DeployedAt]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateAlarms]') AND name = N'IX_TemplateAlarms_RowVersion')
CREATE NONCLUSTERED INDEX [IX_TemplateAlarms_RowVersion] ON [dbo].[TemplateAlarms] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateAlarms]') AND name = N'IX_TemplateAlarms_TemplateId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateAlarms_TemplateId_Name] ON [dbo].[TemplateAlarms] ([TemplateId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateAttributes]') AND name = N'IX_TemplateAttributes_RowVersion')
CREATE NONCLUSTERED INDEX [IX_TemplateAttributes_RowVersion] ON [dbo].[TemplateAttributes] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateAttributes]') AND name = N'IX_TemplateAttributes_TemplateId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateAttributes_TemplateId_Name] ON [dbo].[TemplateAttributes] ([TemplateId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateCompositions]') AND name = N'IX_TemplateCompositions_ComposedTemplateId')
CREATE NONCLUSTERED INDEX [IX_TemplateCompositions_ComposedTemplateId] ON [dbo].[TemplateCompositions] ([ComposedTemplateId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateCompositions]') AND name = N'IX_TemplateCompositions_RowVersion')
CREATE NONCLUSTERED INDEX [IX_TemplateCompositions_RowVersion] ON [dbo].[TemplateCompositions] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateCompositions]') AND name = N'IX_TemplateCompositions_TemplateId_InstanceName')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateCompositions_TemplateId_InstanceName] ON [dbo].[TemplateCompositions] ([TemplateId], [InstanceName]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateFolders]') AND name = N'IX_TemplateFolders_ParentFolderId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateFolders_ParentFolderId_Name] ON [dbo].[TemplateFolders] ([ParentFolderId], [Name]) WHERE ([ParentFolderId] IS NOT NULL);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateNativeAlarmSources]') AND name = N'IX_TemplateNativeAlarmSources_RowVersion')
CREATE NONCLUSTERED INDEX [IX_TemplateNativeAlarmSources_RowVersion] ON [dbo].[TemplateNativeAlarmSources] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateNativeAlarmSources]') AND name = N'IX_TemplateNativeAlarmSources_TemplateId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateNativeAlarmSources_TemplateId_Name] ON [dbo].[TemplateNativeAlarmSources] ([TemplateId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Templates]') AND name = N'IX_Templates_FolderId')
CREATE NONCLUSTERED INDEX [IX_Templates_FolderId] ON [dbo].[Templates] ([FolderId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Templates]') AND name = N'IX_Templates_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Templates_Name] ON [dbo].[Templates] ([Name]) WHERE ([IsDerived]=(0));
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Templates]') AND name = N'IX_Templates_ParentTemplateId')
CREATE NONCLUSTERED INDEX [IX_Templates_ParentTemplateId] ON [dbo].[Templates] ([ParentTemplateId]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Templates]') AND name = N'IX_Templates_RowVersion')
CREATE NONCLUSTERED INDEX [IX_Templates_RowVersion] ON [dbo].[Templates] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateScripts]') AND name = N'IX_TemplateScripts_RowVersion')
CREATE NONCLUSTERED INDEX [IX_TemplateScripts_RowVersion] ON [dbo].[TemplateScripts] ([RowVersion]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TemplateScripts]') AND name = N'IX_TemplateScripts_TemplateId_Name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_TemplateScripts_TemplateId_Name] ON [dbo].[TemplateScripts] ([TemplateId], [Name]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[zbauth].[api_key_audit]') AND name = N'ix_api_key_audit_key_id_created_utc')
CREATE NONCLUSTERED INDEX [ix_api_key_audit_key_id_created_utc] ON [zbauth].[api_key_audit] ([key_id], [created_utc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[zbauth].[api_keys]') AND name = N'ix_api_keys_revoked_utc')
CREATE NONCLUSTERED INDEX [ix_api_keys_revoked_utc] ON [zbauth].[api_keys] ([revoked_utc]);
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'[zbsecrets].[secret]') AND name = N'ix_secret_updated_utc')
CREATE NONCLUSTERED INDEX [ix_secret_updated_utc] ON [zbsecrets].[secret] ([updated_utc]);
-- 2. EF migration history: 65 rows = QA's
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260317065749_InitialSchema') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260317065749_InitialSchema', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260318025613_AddSiteNodeAddresses') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260318025613_AddSiteNodeAddresses', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260321164227_AddGrpcNodeAddresses') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260321164227_AddGrpcNodeAddresses', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260321210402_AddSiteIdToDataConnections') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260321210402_AddSiteIdToDataConnections', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260511144149_AddPrimaryBackupDataConnections') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260511144149_AddPrimaryBackupDataConnections', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260511144239_AddTemplateFolders') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260511144239_AddTemplateFolders', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260512121446_AddDerivedTemplateFields') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260512121446_AddDerivedTemplateFields', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260512122746_MigrateCompositionsToDerived') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260512122746_MigrateCompositionsToDerived', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260512211204_MigrateParametersToJsonSchema') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260512211204_MigrateParametersToJsonSchema', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260513055537_AddInstanceAlarmOverrides') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260513055537_AddInstanceAlarmOverrides', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260517000628_AddDerivedAlarmFields') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260517000628_AddDerivedAlarmFields', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260517010521_EncryptSecretColumns') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260517010521_EncryptSecretColumns', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260517020720_BoundGrpcNodeAddressLength') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260517020720_BoundGrpcNodeAddressLength', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260517073000_HashApiKeyValue') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260517073000_HashApiKeyValue', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260518214444_ContainedDerivedTemplateNames') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260518214444_ContainedDerivedTemplateNames', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260519050659_AddNotificationsTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260519050659_AddNotificationsTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260520142214_AddAuditLogTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260520142214_AddAuditLogTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260520180431_AddSiteCallsTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260520180431_AddSiteCallsTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260521184044_AddAuditLogExecutionId') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260521184044_AddAuditLogExecutionId', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260521193048_AddNotificationOriginExecutionId') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260521193048_AddNotificationOriginExecutionId', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260521210254_AddAuditLogParentExecutionId') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260521210254_AddAuditLogParentExecutionId', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260521220924_AddNotificationOriginParentExecutionId') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260521220924_AddNotificationOriginParentExecutionId', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260523201754_AddAuditLogSourceNode') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260523201754_AddAuditLogSourceNode', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260523201950_AddNotificationSourceNode') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260523201950_AddNotificationSourceNode', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260523202131_AddSiteCallSourceNode') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260523202131_AddSiteCallSourceNode', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260524075016_AddBundleImportIdToAuditLog') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260524075016_AddBundleImportIdToAuditLog', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260528155520_AddInstanceConnectionBindingOverride') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260528155520_AddInstanceConnectionBindingOverride', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260529195700_AddNativeAlarmSources') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260529195700_AddNativeAlarmSources', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260602092753_RetireInboundApiKeyStore') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260602092753_RetireInboundApiKeyStore', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260602113822_CanonicalizeRoles') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260602113822_CanonicalizeRoles', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260602174346_CollapseAuditLogToCanonical') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260602174346_CollapseAuditLogToCanonical', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260615171137_ResyncLdapGroupMappingSeed') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260615171137_ResyncLdapGroupMappingSeed', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260615183757_AddTemplateScriptExecutionTimeout') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260615183757_AddTemplateScriptExecutionTimeout', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260616192131_AddListAttributeElementType') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260616192131_AddListAttributeElementType', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260617234323_AddKpiSampleTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260617234323_AddKpiSampleTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260618060853_AddPendingSecuredWriteTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260618060853_AddPendingSecuredWriteTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260618152548_AddSharedSchema') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260618152548_AddSharedSchema', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260619135543_AddSmsNotifications') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260619135543_AddSmsNotifications', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260619191520_SmsFromNumberOptional') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260619191520_SmsFromNumberOptional', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260626161432_AddPendingDeployment') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260626161432_AddPendingDeployment', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260709105112_FixAuditPurgerRoleGrants') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260709105112_FixAuditPurgerRoleGrants', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260709110614_AddSiteCallsNonTerminalIndex') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260709110614_AddSiteCallsNonTerminalIndex', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260710075422_AddExternalSystemTimeoutSeconds') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260710075422_AddExternalSystemTimeoutSeconds', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260710080636_AddSmtpOAuth2AuthorityScope') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260710080636_AddSmtpOAuth2AuthorityScope', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260710153953_AddKpiRollupHourlyTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260710153953_AddKpiRollupHourlyTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260713142234_AddSiteCallsTerminalIndex') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260713142234_AddSiteCallsTerminalIndex', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260810100836_AddSmtpConfigurationTransport') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260810100836_AddSmtpConfigurationTransport', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260814235335_AddAuditLogAndNotificationCoveringIndexes') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260814235335_AddAuditLogAndNotificationCoveringIndexes', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260815004957_AlignAuditLogEventIdUniqueness') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260815004957_AlignAuditLogEventIdUniqueness', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260815154803_AddBundleUnlockAttemptTable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260815154803_AddBundleUnlockAttemptTable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260815165452_AddDeploymentRecordListSortIndex') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260815165452_AddDeploymentRecordListSortIndex', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260819183326_AddSiteCallsListSortIndex') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260819183326_AddSiteCallsListSortIndex', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260819201210_AddNotificationsListSortIndex') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260819201210_AddNotificationsListSortIndex', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260906034113_AddApiMethodTraceAllCalls') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260906034113_AddApiMethodTraceAllCalls', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260909203046_EnforceGlobalInstanceNamesAndProtectProtocolConfiguration') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260909203046_EnforceGlobalInstanceNamesAndProtectProtocolConfiguration', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260911135501_AddAlarmMesReportable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260911135501_AddAlarmMesReportable', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20260914173147_AddSiteArtifactRevision') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20260914173147_AddSiteArtifactRevision', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261022133907_ReviewRemediationIndexes') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261022133907_ReviewRemediationIndexes', N'10.0.7');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261109200211_AddNativeAlarmSourceMesReportable') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261109200211_AddNativeAlarmSourceMesReportable', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261109203753_PrefixSearchIndexes') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261109203753_PrefixSearchIndexes', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261109211317_AddAuditLogHashChain') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261109211317_AddAuditLogHashChain', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261110032839_AddConfigGraphRowVersions') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261110032839_AddConfigGraphRowVersions', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261110033732_FlipAuditLogClusteredKey') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261110033732_FlipAuditLogClusteredKey', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261110120000_AuditMaintenanceGrants') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261110120000_AuditMaintenanceGrants', N'10.0.13');
IF NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261115221558_RemoveAuditLogHashChain') INSERT dbo.__EFMigrationsHistory (MigrationId, ProductVersion) VALUES (N'20261115221558_RemoveAuditLogHashChain', N'10.0.13');
-- 3. shared-lib schema_version rows (v1, as QA); the app migrators MERGE these too
IF NOT EXISTS (SELECT 1 FROM zbauth.schema_version) INSERT zbauth.schema_version (id, version, applied_utc) VALUES (1, 1, SYSDATETIMEOFFSET());
IF NOT EXISTS (SELECT 1 FROM zbsecrets.schema_version) INSERT zbsecrets.schema_version (id, version, applied_utc) VALUES (1, 1, CONVERT(nvarchar(64), SYSDATETIMEOFFSET(), 127));
-- 4. migration seed rows (EF HasData + later UPDATEs, final state = QA); sb-role-mappings-prod.sql adds the _PROD rows after these
IF NOT EXISTS (SELECT 1 FROM dbo.LdapGroupMappings)
BEGIN
SET IDENTITY_INSERT dbo.LdapGroupMappings ON;
INSERT dbo.LdapGroupMappings (Id, LdapGroupName, Role) VALUES
(1, N'SCADA-Admins', N'Administrator'), (2, N'SCADA-Designers', N'Designer'), (3, N'SCADA-Deploy-All', N'Deployer'),
(4, N'SCADA-Deploy-SiteA', N'Deployer'), (5, N'SCADA-Viewers', N'Viewer');
SET IDENTITY_INSERT dbo.LdapGroupMappings OFF;
END
COMMIT;
SELECT (SELECT COUNT(*) FROM sys.indexes i JOIN sys.tables t ON t.object_id=i.object_id WHERE i.type=2) AS nonclustered_indexes_expect_104,
(SELECT COUNT(*) FROM dbo.__EFMigrationsHistory) AS migrations_expect_65,
(SELECT MAX(MigrationId) FROM dbo.__EFMigrationsHistory) AS last_migration,
(SELECT COUNT(*) FROM dbo.LdapGroupMappings) AS ldap_mappings_expect_5;
@@ -44,7 +44,7 @@ Ask the owner for each of these explicitly; none is implied by the staging reque
| Needed for | What | Question | Where it goes |
|---|---|---|---|
| Phase 3, 5 | PROD SQL Server, empty `ScadaBridge` DB, `scadabridge_svc` login (`db_owner`), backup target | Q1 | value files `ScadaBridge__Database__ConfigurationDb.txt` and `Secrets__SqlServer__ConnectionString.txt` |
| Phase 3, 5 | **Q1 partly answered 2026-11-20** (owner file `ScadaBridge/prod.txt`): `wondersqlpd.zmr.zimmer.com` (= `WONDER-SQL-VP03`, SQL 2022 CU16), DB `ScadaBridge`, SQL login `wwpdsbrw` (db_datareader + db_datawriter, **no DDL**). The DB was pre-built by a DBA at 2026-11-20 09:37: all 46 tables, PKs, 27 FKs, defaults, computed columns and the AuditLog partition scheme match QA, all tables empty, **but none of the 104 nonclustered/unique indexes, no `__EFMigrationsHistory` rows, no `schema_version` rows**. As is, the central refuses to start (65 pending migrations) and the zbauth migrator's `CREATE INDEX` is denied. **Needed: a DBA runs `sql\prod-complete-dba-schema.sql`** (sha `17e0e7d6bb67…`; idempotent; compiled OK on PROD under NOEXEC), not `scadabridge-schema-2e0ce81e.sql`. Still open: backup target, who runs DDL | Q1 | value files `ScadaBridge__Database__ConfigurationDb.txt` and `Secrets__SqlServer__ConnectionString.txt` (`User ID=wwpdsbrw`; password from `prod.txt`, move it to the Keychain) |
| Phase 4 | Prod Galaxy Repository SQL + alarm area | Q2 | `MxGateway__Galaxy__ConnectionString.txt`; replace `__Q2_ALARM_EXPRESSION__` in `mxgw.env` (`\\<GR node>\Galaxy!<area>`) |
| Phase 6 | `SiteId` | Q8 | replace `__Q8_SITE_ID__` in both `appsettings.Site.json.prod-*` |
| Phase 2–6 | Firewall: the §4 rows, incl. the Overview rows (5320; centrals → PAR 8084/5130) | Q5 | IT request; `preflight-prod.ps1` shows open / refused / timeout per path |
@@ -67,8 +67,8 @@ the install scripts: `scadabridge.kek` on vp03 only, then carried to vp04 and bo
`winrm ps <box> '& E:\psrem-stage\prod-common\preflight-prod.ps1 -SqlHost <Q1> -GrHost <Q2>'`. Gates: rootca + LDAPS
ok, greenfield paths/ports free, paths `refused` (not `timeout`), staged hashes ok. Optional:
`otel-54\Install-OtelCollector.ps1 -StageDir E:\psrem-stage\otel-54 -Tier PROD -NssmPath E:\psrem-stage\prod-common\nssm.exe`.
3. **Phase 3 SQL** (by `sqlcmd -I -b` or a DBA): `sql\scadabridge-schema-2e0ce81e.sql` → gate 65 migrations;
`sql\zbsecrets-schema-v1.sql`; `sql\sb-role-mappings-prod.sql` → 5 `_PROD` rows after ids 1–5; first backup.
3. **Phase 3 SQL** (DBA, DDL rights; `wwpdsbrw` has none): the DB already holds the tables, so run `sql\prod-complete-dba-schema.sql` (indexes + history + schema_version) → gate 65 migrations, 104 nonclustered indexes, LdapGroupMappings ids 1–5; re-run the QA-vs-PROD schema diff (2026-11-20 record) → 0 index differences;
(`sql\zbsecrets-schema-v1.sql` is now redundant: zbsecrets already exists); `sql\sb-role-mappings-prod.sql` (DML, `wwpdsbrw` can run it) → 5 `_PROD` rows after ids 1–5; first backup.
4. **Phase 4 mxgw on vp03, then vp04:** `mxgw-e74918cc\install-mxgw.ps1 -Mode dry -ValuesDir <dir>`, then `-Mode real`;
`prod-common\seed-secret-prod.ps1 -Target MxAccessGw -ValueFile <file>`; `nssm start MxAccessGw`; §3A.5 checks; mint
client keys (Q4). PAR boxes only after the Q3 gate.