-- ===================================================================
-- MARS-1049 ROLLBACK COMPONENT: Revoke Permissions for Hash Tracking
-- ===================================================================
-- Purpose: Revoke CT_MRDS permissions granted during MARS-1049 installation
-- Author: Grzegorz Michalski
-- Date: 2025-11-25
-- Version: 1.0.0
-- Step: 90 (Last step - execute after package rollback)
--
-- ROLLBACK OPERATION:
-- Revokes SELECT ANY DICTIONARY from CT_MRDS
--
-- WARNING:
-- This may affect other packages that depend on cross-schema hash tracking
-- Only revoke if no other packages in ODS or other schemas need tracking
--
-- USAGE:
-- - Execute as ADMIN user (system privilege revoke required)
-- - Should be last step in MARS-1049 rollback (after restoring packages)
-- ===================================================================

PROMPT ===============================================
PROMPT Revoking cross-schema hash tracking permissions
PROMPT ===============================================

-- Check if privilege exists before revoking
SELECT PRIVILEGE, GRANTEE 
FROM DBA_SYS_PRIVS 
WHERE GRANTEE = 'CT_MRDS' 
  AND PRIVILEGE = 'SELECT ANY DICTIONARY';

-- Revoke SELECT ANY DICTIONARY from CT_MRDS
REVOKE SELECT ANY DICTIONARY FROM CT_MRDS;

PROMPT Revoked SELECT ANY DICTIONARY from CT_MRDS

PROMPT ===============================================
PROMPT Permission revocation completed
PROMPT ===============================================
PROMPT
PROMPT CT_MRDS can NO LONGER:
PROMPT - Read ALL_SOURCE for schemas other than CT_MRDS
PROMPT - Calculate SHA256 hashes for packages in ODS and other schemas
PROMPT
PROMPT WARNING: This may cause NULL hash values for cross-schema packages
PROMPT          If other packages depend on this, re-grant the privilege
PROMPT ===============================================
