-- MARS-828: Rename threshold columns for consistency
-- Author: Grzegorz Michalski  
-- Date: 2026-01-28
-- Description: Renames threshold columns to use consistent ARCHIVE_THRESHOLD_* prefix pattern
--              Old naming was inconsistent (DAYS_FOR vs FILES_COUNT_OVER)
--              New naming groups all threshold columns with common prefix

PROMPT ========================================
PROMPT MARS-828: Renaming threshold columns for consistency
PROMPT ========================================

-- Rename threshold columns to consistent ARCHIVE_THRESHOLD_* pattern
ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN DAYS_FOR_ARCHIVE_THRESHOLD TO ARCHIVE_THRESHOLD_DAYS;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN FILES_COUNT_OVER_ARCHIVE_THRESHOLD TO ARCHIVE_THRESHOLD_FILES_COUNT;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN BYTES_SUM_OVER_ARCHIVE_THRESHOLD TO ARCHIVE_THRESHOLD_BYTES_SUM;

ALTER TABLE CT_MRDS.A_SOURCE_FILE_CONFIG 
RENAME COLUMN ROWS_COUNT_OVER_ARCHIVE_THRESHOLD TO ARCHIVE_THRESHOLD_ROWS_COUNT;

-- Verify column renames
PROMPT ========================================
PROMPT Verifying threshold column renames...
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%'
ORDER BY column_id;

PROMPT ========================================
PROMPT Expected columns:
PROMPT   ARCHIVE_THRESHOLD_DAYS
PROMPT   ARCHIVE_THRESHOLD_FILES_COUNT
PROMPT   ARCHIVE_THRESHOLD_BYTES_SUM
PROMPT   ARCHIVE_THRESHOLD_ROWS_COUNT
PROMPT ========================================

PROMPT Threshold columns renamed successfully
PROMPT ========================================
