module.exports = `
SELECT 
    EVENT_SCHEMA,
    EVENT_NAME,
    DEFINER,
    EVENT_TYPE,
    EXECUTE_AT,
    INTERVAL_VALUE,
    INTERVAL_FIELD,
    CREATED,
    LAST_EXECUTED,
    LAST_ALTERED,
    STARTS,
    ENDS,
    STATUS,
    ON_COMPLETION,
        CONCAT(
        'CREATE EVENT \`', EVENT_NAME, '\` ',
        CASE WHEN EVENT_TYPE = 'RECURRING' THEN
            'ON SCHEDULE EVERY ' 
            ELSE 'ON SCHEDULE AT ' 
        END,
        CASE WHEN EVENT_TYPE = 'RECURRING' THEN 
            CONCAT(INTERVAL_VALUE, ' ', INTERVAL_FIELD)
            ELSE DATE_FORMAT(EXECUTE_AT, '%Y-%m-%d %H:%i:%s') 
        END,
        ' DO ',
        EVENT_DEFINITION
    ) AS CREATE_SQL
FROM INFORMATION_SCHEMA.EVENTS
WHERE EVENT_SCHEMA = '#DATABASE#' AND EVENT_NAME =OBJECT_ID_CONDITION
`;
