-- MARS-828: Rollback threshold column renames
-- Author: Grzegorz Michalski
-- Date: 2026-01-28
-- Description: Reverts threshold columns back to original naming

PROMPT ========================================
PROMPT MARS-828: Rolling back threshold column renames
PROMPT ========================================

-- Revert threshold columns to original names
ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN ARCHIVE_THRESHOLD_DAYS TO DAYS_FOR_ARCHIVE_THRESHOLD;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN ARCHIVE_THRESHOLD_FILES_COUNT TO FILES_COUNT_OVER_ARCHIVE_THRESHOLD;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN ARCHIVE_THRESHOLD_BYTES_SUM TO BYTES_SUM_OVER_ARCHIVE_THRESHOLD;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN ARCHIVE_THRESHOLD_ROWS_COUNT TO ROWS_COUNT_OVER_ARCHIVE_THRESHOLD;

-- Verify rollback
PROMPT ========================================
PROMPT Verifying threshold column rollback...
PROMPT ========================================

SELECT 
    column_name,
    data_type,
    data_length
FROM all_tab_columns 
WHERE owner = 'CT_MRDS' 
  AND table_name = 'A_SOURCE_FILE_CONFIG'
  AND (column_name LIKE '%ARCHIVE_THRESHOLD%' OR column_name LIKE 'DAYS_FOR%')
ORDER BY column_id;

PROMPT ========================================
PROMPT Expected original columns:
PROMPT   DAYS_FOR_ARCHIVE_THRESHOLD
PROMPT   FILES_COUNT_OVER_ARCHIVE_THRESHOLD
PROMPT   BYTES_SUM_OVER_ARCHIVE_THRESHOLD
PROMPT   ROWS_COUNT_OVER_ARCHIVE_THRESHOLD
PROMPT ========================================

PROMPT Threshold column renames rolled back successfully
PROMPT ========================================
