-- ============================================================================
-- MARS-1409 Rollback 93C: Restore TRG_A_WORKFLOW_HISTORY trigger
-- ============================================================================
-- Purpose: Restore trigger to pre-MARS-1409 state
--          Removes INGESTED status update logic from A_SOURCE_FILE_RECEIVED
-- ============================================================================

PROMPT Restoring TRG_A_WORKFLOW_HISTORY (rollback_version)...
@@rollback_version/TRG_A_WORKFLOW_HISTORY.sql

PROMPT
DECLARE
    v_status VARCHAR2(20);
BEGIN
    SELECT status INTO v_status
    FROM all_objects
    WHERE owner = 'CT_MRDS'
      AND object_name = 'TRG_A_WORKFLOW_HISTORY'
      AND object_type = 'TRIGGER';
    DBMS_OUTPUT.PUT_LINE('TRG_A_WORKFLOW_HISTORY restored, status: ' || v_status);
EXCEPTION
    WHEN NO_DATA_FOUND THEN
        RAISE_APPLICATION_ERROR(-20001, 'ERROR: TRG_A_WORKFLOW_HISTORY not found after rollback');
END;
/
