-- Creating a sequence for Document logs
CREATE SEQUENCE IF NOT EXISTS STG.DOCUMENT_ID START = 1 INCREMENT = 1;

-- Creating a sequence for Batch logs
CREATE SEQUENCE IF NOT EXISTS STG.BATCH_ID START = 1 INCREMENT = 1;

-- Creating the 'document_logs' table
CREATE TABLE IF NOT EXISTS STG.DOCUMENT_LOGS 
(
    DOCUMENT_ID NUMERIC DEFAULT STG.DOCUMENT_ID.NEXTVAL,
    BATCH_ID NUMERIC NOT NULL,
    JOB_ID VARCHAR,
    STAGE VARCHAR,
    TEXTRACT_STATUS VARCHAR,
    BUCKET_NAME VARCHAR NOT NULL,
    FILE_NAME VARCHAR NOT NULL,
    FILE_PATH VARCHAR,
    DOCUMENT_TYPE VARCHAR,
    PAYER_SIGNED BOOLEAN,
    PROVIDER_SIGNED BOOLEAN,
    GROUP_ID VARCHAR,
    CREATED_TIME TIMESTAMP,
    MODIFIED_TIME TIMESTAMP,
    CREATED_BY VARCHAR,
    MODIFIED_BY VARCHAR,
    ORIGINAL_FILE_EXTENSION VARCHAR,
    NO_OF_PAGES NUMERIC,
    FILE_SIZE NUMERIC,
    PRIMARY KEY (DOCUMENT_ID)
);

-- Creating the 'batch_logs' table
CREATE TABLE IF NOT EXISTS STG.BATCH_LOGS (
    BATCH_ID NUMERIC DEFAULT STG.BATCH_ID.NEXTVAL,
    CLIENT_ID VARCHAR,
    EXECUTION_START_TIME TIMESTAMP,
    NO_OF_DOCUMENTS NUMBER,
    USER_NAME VARCHAR,
    PRIMARY KEY (BATCH_ID)
);

-- Creating the 'client_logs' table
CREATE TABLE IF NOT EXISTS STG.CLIENT_LOGS (
    CLIENT_ID VARCHAR ,
    CLIENT_NAME VARCHAR,
    BUCKET_NAME VARCHAR,
    PRIMARY KEY (CLIENT_ID)
);
