Re-enable specific automations after app update in Oracle APEX

One thing that can be a bit annoying is that APEX automatically disables all automations whenever an application is overwritten with a new version.
I usually automate much of the pipeline for generating and deploying database objects and applications to other servers, and I noticed that, by default, automations are always disabled after an app update.
To work around this, I created the script below, which I run after each successful app update. You can customize it to your needs by specifying the automations you want to re-enable. You can also modify the script in any way that suits your workflow.
SET SERVEROUTPUT ON
BEGIN
apex_util.set_workspace('YOUR_WORKSPACE_NAME');
apex_session.create_session(
p_app_id => 117, --App ID
p_page_id => 1, --Any Page in the App
p_username => 'VALTER' ); -- Any valid APEX User
--Enable specific automation
apex_automation.enable(
p_application_id => 117, --App Id
p_static_id => 'emitir-espelho-retorno-nf' ); -- Static id
--Destroying the session
apex_session.delete_session;
END;
/
You can also create a simple loop to enable all your automations, or implement any custom logic based on the results from this view:
SELECT * FROM APEX_APPL_AUTOMATION
References:
https://docs.oracle.com/en/database/oracle/apex/24.1/aeapi/APEX_AUTOMATION_ENABLE-Procedure.html



![Something Between VARCHAR2 and CLOB: VARCHAR2 on Steroids [MAX_STRING_SIZE]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1760047927511%2Fd21b9892-29f1-42bc-8e1b-7c2b4d0a642d.png&w=3840&q=75)

