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

PROMPT Restoring trigger A_WORKFLOW_HISTORY (rollback_version)...
@@rollback_version/A_WORKFLOW_HISTORY.sql

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