deploy(prod): PROD ScadaBridge DB data rows applied as wwpdsbrw (history 65, schema_version, mappings 1-10); DBA indexes owed (scadaproj#59)

Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
This commit is contained in:
Joseph Doherty
2026-11-20 14:49:29 -05:00
parent d88e820a1c
commit b5eff81dbc
3 changed files with 108 additions and 3 deletions
@@ -45,4 +45,14 @@ QA's 65 history rows, both `schema_version` v1 rows, and the 5 seed mappings. On
different migration state. Compiled against PROD under `SET NOEXEC ON` (names bind; nothing ran; history still 0). 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). 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.
## Follow-up 2026-11-20 19:48Z: DML half applied (owner: "start setting up the db, ill have the indices setup by dba after")
As `wwpdsbrw`, `sql/prod-app-dml-setup.sql` (no IDENTITY_INSERT: the identity was unused, seed 1, ids checked in-transaction):
65 history rows (last `20261115221558_RemoveAuditLogHashChain`), `zbauth` + `zbsecrets` `schema_version` v1 (19:48:50Z),
`LdapGroupMappings` 1–5 (SCADA-* seed, as QA). Then `sb-role-mappings-prod.sql`: ids 6–10 = the five `_PROD` groups (D-P6).
Re-run of the DML script: no change (idempotent). Nonclustered indexes still **0**.
**Open (scadaproj#59):** DBA runs `prod-complete-dba-schema.sql` (only the 104 `CREATE INDEX` act now). Until then the
central must not start: the migration check passes now, but uniqueness is unenforced and the zbauth/zbsecrets migrators'
`CREATE INDEX` is denied. Verify: index count 104, schema diff vs QA 0 index differences.
@@ -0,0 +1,95 @@
-- ScadaBridge PROD (wondersqlpd / ScadaBridge): the DML half of the schema completion, run as the app login wwpdsbrw
-- (db_datareader + db_datawriter, no DDL / no ALTER) on 2026-11-20. The DDL half (104 nonclustered indexes) is still owed by
-- the DBA: prod-complete-dba-schema.sql (its DML parts are guarded and skip once this has run).
-- Writes: 65 __EFMigrationsHistory rows (= QA), zbauth/zbsecrets schema_version v1, LdapGroupMappings seed ids 1-5.
-- No IDENTITY_INSERT (needs ALTER): relies on the identity never having been used (seed 1, last_value NULL) and checks the ids.
-- Idempotent; one transaction; refuses any other starting state.
SET XACT_ABORT ON; SET NOCOUNT ON;
IF DB_NAME() <> N'ScadaBridge' THROW 50000, 'wrong database', 1;
IF EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory) AND NOT EXISTS (SELECT 1 FROM dbo.__EFMigrationsHistory WHERE MigrationId = N'20261115221558_RemoveAuditLogHashChain')
THROW 50001, 'history present but not at 2e0ce81e', 1;
BEGIN TRAN;
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');
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));
IF NOT EXISTS (SELECT 1 FROM dbo.LdapGroupMappings)
BEGIN
IF (SELECT last_value FROM sys.identity_columns WHERE object_id = OBJECT_ID(N'dbo.LdapGroupMappings')) IS NOT NULL
THROW 50002, 'LdapGroupMappings identity already used; ids would not be 1-5 - needs the DBA script (IDENTITY_INSERT)', 1;
INSERT dbo.LdapGroupMappings (LdapGroupName, Role) VALUES (N'SCADA-Admins', N'Administrator');
INSERT dbo.LdapGroupMappings (LdapGroupName, Role) VALUES (N'SCADA-Designers', N'Designer');
INSERT dbo.LdapGroupMappings (LdapGroupName, Role) VALUES (N'SCADA-Deploy-All', N'Deployer');
INSERT dbo.LdapGroupMappings (LdapGroupName, Role) VALUES (N'SCADA-Deploy-SiteA', N'Deployer');
INSERT dbo.LdapGroupMappings (LdapGroupName, Role) VALUES (N'SCADA-Viewers', N'Viewer');
END
IF (SELECT COUNT(*) FROM dbo.LdapGroupMappings WHERE (Id=1 AND LdapGroupName=N'SCADA-Admins') OR (Id=2 AND LdapGroupName=N'SCADA-Designers') OR (Id=3 AND LdapGroupName=N'SCADA-Deploy-All') OR (Id=4 AND LdapGroupName=N'SCADA-Deploy-SiteA') OR (Id=5 AND LdapGroupName=N'SCADA-Viewers')) <> 5
THROW 50003, 'seed ids are not 1-5 as on QA', 1;
IF (SELECT COUNT(*) FROM dbo.__EFMigrationsHistory) <> 65 THROW 50004, 'history count is not 65', 1;
COMMIT;
SELECT (SELECT COUNT(*) FROM dbo.__EFMigrationsHistory) migrations, (SELECT MAX(MigrationId) FROM dbo.__EFMigrationsHistory) last_migration,
(SELECT COUNT(*) FROM zbauth.schema_version) zbauth_sv, (SELECT COUNT(*) FROM zbsecrets.schema_version) zbsecrets_sv;
SELECT Id, LdapGroupName, Role FROM dbo.LdapGroupMappings ORDER BY Id;
@@ -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 | | Needed for | What | Question | Where it goes |
|---|---|---|---| |---|---|---|---|
| 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 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. **DML half DONE 2026-11-20 19:48Z** as `wwpdsbrw` (`sql\prod-app-dml-setup.sql`: 65 history rows, both `schema_version` v1, seed ids 1–5, plus `sb-role-mappings-prod.sql` → `_PROD` ids 6–10). **⏰ REMINDER (scadaproj#59): the DBA still owes the 104 indexes** → `sql\prod-complete-dba-schema.sql` (only its `CREATE INDEX` lines do anything now). **Do not start the central until index count = 104.** Still open: backup target | 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 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 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 | | 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,7 +67,7 @@ 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 `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: 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`. `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** (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; 3. **Phase 3 SQL** — data rows DONE 2026-11-20; **gate: scadaproj#59 closed (DBA indexes) before Phase 5.** (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. (`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`; 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 `prod-common\seed-secret-prod.ps1 -Target MxAccessGw -ValueFile <file>`; `nssm start MxAccessGw`; §3A.5 checks; mint