b418408c0f
Component-AuditLog (Security & Tamper-Evidence now a removal note, archive format v2, config), Component-CLI, Component-ManagementService, HighLevelReqs AL-11/AL-12, docs/components/CLI, the CLI README, alog.md §11.4/§15 and CLAUDE.md. New production script docs/plans/sql/RemoveAuditLogHashChain.sql (idempotent, from migration 64); AddAuditLogHashChain.sql marked superseded. Historical plans, deployment records and deploy-prep packs are left as written. Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
95 lines
3.8 KiB
Transact-SQL
95 lines
3.8 KiB
Transact-SQL
-- RemoveAuditLogHashChain (2026-11-15). Removes the AuditLog hash chain and the two-login maintenance grants at IT
|
|
-- security's request: IX_AuditLog_Unchained/IX_AuditLog_ChainSeq, the scadabridge_audit_chainer role (members first),
|
|
-- dbo.AuditLogChainHead/AuditLogChainTombstone, AuditLog.ChainSeq/RowHash, and the purger's ALTER ANY DATASPACE +
|
|
-- UPDATE (SourceNode) grants. scadabridge_audit_writer/_purger themselves stay. Idempotent (generated with --idempotent
|
|
-- from 20261110120000_AuditMaintenanceGrants, migration 64 = DEV vd03 and QA vq03/vq04 on 2026-11-15).
|
|
-- DEPLOY GATE: apply with both centrals stopped, together with binaries that contain this migration; older binaries
|
|
-- map ChainSeq/RowHash and fail against the migrated table. Remove AuditLog__HashChain__* from the Central service env
|
|
-- in the same window (the new binaries ignore it with a warning). Rollback: the migration's Down recreates the schema.
|
|
BEGIN TRANSACTION;
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
|
|
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_AuditLog_ChainSeq' AND object_id = OBJECT_ID('dbo.AuditLog'))
|
|
EXEC(N'DROP INDEX IX_AuditLog_ChainSeq ON dbo.AuditLog;');
|
|
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_AuditLog_Unchained' AND object_id = OBJECT_ID('dbo.AuditLog'))
|
|
EXEC(N'DROP INDEX IX_AuditLog_Unchained ON dbo.AuditLog;');
|
|
END;
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
|
|
IF DATABASE_PRINCIPAL_ID('scadabridge_audit_chainer') IS NOT NULL
|
|
BEGIN
|
|
IF COL_LENGTH('dbo.AuditLog', 'ChainSeq') IS NOT NULL
|
|
EXEC(N'REVOKE UPDATE (ChainSeq, RowHash) ON dbo.AuditLog FROM scadabridge_audit_chainer;');
|
|
EXEC(N'REVOKE SELECT ON dbo.AuditLog FROM scadabridge_audit_chainer;');
|
|
|
|
DECLARE @dropMembers nvarchar(max) = N'';
|
|
SELECT @dropMembers = @dropMembers + N'ALTER ROLE scadabridge_audit_chainer DROP MEMBER ' + QUOTENAME(m.name) + N';' + CHAR(10)
|
|
FROM sys.database_role_members rm
|
|
JOIN sys.database_principals r ON r.principal_id = rm.role_principal_id
|
|
JOIN sys.database_principals m ON m.principal_id = rm.member_principal_id
|
|
WHERE r.name = N'scadabridge_audit_chainer';
|
|
EXEC sp_executesql @dropMembers;
|
|
|
|
EXEC(N'DROP ROLE scadabridge_audit_chainer;');
|
|
END
|
|
END;
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
|
|
IF OBJECT_ID('dbo.AuditLogChainHead', 'U') IS NOT NULL
|
|
EXEC(N'DROP TABLE dbo.AuditLogChainHead;');
|
|
IF OBJECT_ID('dbo.AuditLogChainTombstone', 'U') IS NOT NULL
|
|
EXEC(N'DROP TABLE dbo.AuditLogChainTombstone;');
|
|
END;
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
|
|
IF COL_LENGTH('dbo.AuditLog', 'ChainSeq') IS NOT NULL
|
|
EXEC(N'ALTER TABLE dbo.AuditLog DROP COLUMN ChainSeq;');
|
|
IF COL_LENGTH('dbo.AuditLog', 'RowHash') IS NOT NULL
|
|
EXEC(N'ALTER TABLE dbo.AuditLog DROP COLUMN RowHash;');
|
|
END;
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
|
|
IF DATABASE_PRINCIPAL_ID('scadabridge_audit_purger') IS NOT NULL
|
|
BEGIN
|
|
EXEC(N'REVOKE ALTER ANY DATASPACE FROM scadabridge_audit_purger;');
|
|
EXEC(N'REVOKE UPDATE (SourceNode) ON dbo.AuditLog FROM scadabridge_audit_purger;');
|
|
END
|
|
END;
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM [__EFMigrationsHistory]
|
|
WHERE [MigrationId] = N'20261115221558_RemoveAuditLogHashChain'
|
|
)
|
|
BEGIN
|
|
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
|
|
VALUES (N'20261115221558_RemoveAuditLogHashChain', N'10.0.13');
|
|
END;
|
|
|
|
COMMIT;
|
|
GO
|
|
|