-- Auto-install script for MARS-828 (bypasses ACCEPT prompts)
-- Usage: sql "ADMIN/Cloudpass#34@ggmichalski_high" @auto_install.sql

SET SERVEROUTPUT ON SIZE UNLIMITED
SET VERIFY OFF
SET FEEDBACK ON
SET ECHO OFF

-- Create log directory
host mkdir log 2>nul

-- Generate SPOOL filename
var filename VARCHAR2(100)
BEGIN
    :filename := 'log/INSTALL_MARS_828_' || SYS_CONTEXT('USERENV', 'CON_NAME') || '_' || TO_CHAR(SYSDATE,'YYYYMMDD_HH24MISS') || '.log';
END;
/
column filename new_value _filename
select :filename filename from dual;
spool &_filename

PROMPT
PROMPT ============================================================================
PROMPT MARS-828 Installation Starting (AUTO MODE)
PROMPT ============================================================================
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') AS install_start FROM DUAL;
PROMPT ============================================================================

PROMPT
PROMPT Step 1/7: Adding archival strategy columns
PROMPT ===================================================================
@@../01_MARS_828_install_add_archival_strategy_columns.sql

PROMPT
PROMPT Step 2/7: Creating validation trigger
PROMPT ======================================
@@../02_MARS_828_install_archival_strategy_trigger.sql

PROMPT
PROMPT Step 3/7: Deploying FILE_ARCHIVER Spec v3.0.0
PROMPT ===============================================================
@@../03_MARS_828_install_CT_MRDS_FILE_ARCHIVER_SPEC.sql

PROMPT
PROMPT Step 4/7: Deploying FILE_ARCHIVER Body v3.0.0
PROMPT ======================================================
@@../04_MARS_828_install_CT_MRDS_FILE_ARCHIVER_BODY.sql

PROMPT
PROMPT Step 5/7: Verifying installation
PROMPT =================================
@@../05_MARS_828_verify_installation.sql

PROMPT
PROMPT Step 6/7: Tracking package versions
PROMPT ====================================
@@../track_package_versions.sql

PROMPT
PROMPT Step 7/7: Verifying tracked packages
PROMPT =====================================
@@../verify_packages_version.sql

PROMPT
PROMPT ============================================================================
PROMPT MARS-828 Installation Completed
PROMPT ============================================================================
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') AS install_end FROM DUAL;
PROMPT ============================================================================

spool off
quit;
