Refactor MARS-956 package for C2D MPEC data export

- Updated README.md to enhance clarity on the one-time export process, including detailed prerequisites, data structure, and validation steps.
- Revised install_mars956.sql to streamline installation commands and improve logging mechanisms.
- Modified rollback_mars956.sql to include user confirmation before proceeding with deletions and to clarify rollback steps.
- Removed unnecessary tracking and validation scripts (track_package_versions.sql, validate_export.sql, verify_packages_version.sql) to simplify the package structure.
- Enhanced error handling and validation checks throughout the installation and rollback processes.
This commit is contained in:
Grzegorz Michalski
2026-02-12 09:56:37 +01:00
parent f2bcdb3a76
commit a7d286b1e6
13 changed files with 1871 additions and 661 deletions

View File

@@ -1,85 +1,75 @@
-- ===================================================================
-- MARS-956 ROLLBACK SCRIPT
-- ===================================================================
-- Purpose: Rollback/cleanup for MARS-956 C2D MPEC historical data export
-- Author: Grzegorz Michalski
-- Date: 2026-02-11
--
-- NOTE: This is primarily for cleanup of log entries and tracking data.
-- The exported CSV files would need to be manually removed from
-- the DATA bucket if rollback is required.
-- MARS-956 ROLLBACK SCRIPT: C2D MPEC Data Export Rollback
-- ===================================================================
-- Purpose: Rollback MARS-956 - Delete exported CSV files and file registrations
-- WARNING: This will DELETE all exported data files and registrations!
-- Author: System Generated
-- Date: 2026-02-12
-- Start logging
spool rollback_mars956.log
-- Dynamic spool file generation (using SYS_CONTEXT - no DBA privileges required)
-- IMPORTANT: Ensure log/ directory exists before SPOOL (use host mkdir)
host mkdir log 2>nul
var filename VARCHAR2(100)
BEGIN
:filename := 'log/ROLLBACK_MARS_956_' || SYS_CONTEXT('USERENV', 'CON_NAME') || '_' || TO_CHAR(SYSDATE,'YYYYMMDD_HH24MISS') || '.log';
END;
/
column filename new_value _filename
select :filename filename from dual;
spool &_filename
SET ECHO OFF
SET TIMING ON
SET SERVEROUTPUT ON SIZE UNLIMITED
SET PAUSE OFF
PROMPT =========================================================================
PROMPT MARS-956 ROLLBACK - Cleanup Historical C2D MPEC Export
PROMPT MARS-956: Rollback C2D MPEC Data Export
PROMPT =========================================================================
PROMPT Rollback Start:
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') AS ROLLBACK_START FROM DUAL;
SET SERVEROUTPUT ON SIZE 1000000
PROMPT
PROMPT Step 1: Review Export Activity
PROMPT =========================================================================
-- Show what was exported
PROMPT Recent MARS-956 export activity:
SELECT TO_CHAR(EVENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') AS EXPORT_TIME,
PROCEDURE_NAME,
EVENT_TYPE,
EVENT_MESSAGE
FROM CT_MRDS.A_PROCESS_LOG
WHERE PACKAGE_NAME = 'MARS-956'
OR PROCEDURE_NAME LIKE '%MARS_956%'
ORDER BY EVENT_TIMESTAMP DESC;
PROMPT
PROMPT Step 2: Cleanup Log Entries (Optional)
PROMPT =========================================================================
-- Optionally remove MARS-956 log entries (uncomment if needed)
/*
DELETE FROM CT_MRDS.A_PROCESS_LOG
WHERE PACKAGE_NAME = 'MARS-956'
OR PROCEDURE_NAME LIKE '%MARS_956%';
PROMPT Deleted log entries:
SELECT SQL%ROWCOUNT AS DELETED_ROWS FROM DUAL;
COMMIT;
*/
PROMPT Log cleanup skipped (uncomment DELETE statement if cleanup needed)
PROMPT
PROMPT Step 3: Manual Steps Required
PROMPT =========================================================================
PROMPT MANUAL CLEANUP REQUIRED:
PROMPT WARNING: This will DELETE exported CSV files and file registrations!
PROMPT - ODS bucket: mrds_data_dev/ODS/C2D/
PROMPT - File registrations: A_SOURCE_FILE_RECEIVED entries
PROMPT
PROMPT If complete rollback is needed, manually remove CSV files from DATA bucket:
PROMPT - mrds_data_dev/ODS/C2D/C2D_MPEC_ADMIN/*.csv
PROMPT - mrds_data_dev/ODS/C2D/C2D_MPEC_CONTENT/*.csv
PROMPT - mrds_data_dev/ODS/C2D/C2D_MPEC_CONTENT_CRITERION/*.csv
PROMPT
PROMPT Use OCI CLI or console to remove files:
PROMPT oci os object list --bucket-name mrds_data_dev --prefix "ODS/C2D/C2D_MPEC"
PROMPT oci os object delete --bucket-name mrds_data_dev --name "path/to/file.csv"
PROMPT
PROMPT =========================================================================
PROMPT MARS-956 ROLLBACK SUMMARY
PROMPT Only proceed if export failed and needs to be restarted!
PROMPT =========================================================================
PROMPT Rollback Completed:
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') AS ROLLBACK_END FROM DUAL;
-- Confirm rollback with user
ACCEPT continue CHAR PROMPT 'Type YES to continue with rollback, or Ctrl+C to abort: '
WHENEVER SQLERROR EXIT SQL.SQLCODE
BEGIN
IF '&continue' IS NULL OR TRIM('&continue') IS NULL OR UPPER(TRIM('&continue')) != 'YES' THEN
RAISE_APPLICATION_ERROR(-20001, 'Rollback aborted by user');
END IF;
END;
/
WHENEVER SQLERROR CONTINUE
PROMPT
PROMPT Note: This rollback script primarily cleans up log entries.
PROMPT Exported CSV files require manual removal from DATA bucket.
PROMPT
PROMPT =========================================================================
PROMPT Step 1: Delete File Registrations
PROMPT =========================================================================
@@91_MARS_956_rollback_file_registrations.sql
PROMPT
PROMPT =========================================================================
PROMPT Step 2: Clean Process Logs
PROMPT =========================================================================
@@92_MARS_956_rollback_process_logs.sql
PROMPT
PROMPT =========================================================================
PROMPT Step 3: Verify Rollback Completion
PROMPT =========================================================================
@@99_MARS_956_verify_rollback.sql
PROMPT
PROMPT =========================================================================
PROMPT MARS-956 Rollback - COMPLETED
PROMPT =========================================================================
PROMPT Check the log file for complete rollback details.
PROMPT =========================================================================
spool off
quit;