# Oracle APEX Application Migration:

Migrating an Oracle APEX application from Development to Test and to Production may look easy. Export the application, import it into the target workspace, and test it.

A page might work perfectly in Development but fail in UAT because a database view is missing. A REST integration might stop working because the target environment has different credentials. Even a missing database grant can prevent an entire workflow from working.

Many migration issues are related to dependencies outside the APEX application itself. Database objects, security settings, external integrations, and environment-specific configurations.

In this blog we will follow approach one should follow when moving an Oracle APEX application across Development, Test, and Production environments.

**1\. Identify everything the application depends on:**

Before preparing deployment scripts, first understand the complete application scope.

An APEX application can depend on several components:

1. PL/SQL packages and procedures
2. Sequences and triggers
3. Synonyms and database grants
4. Shared Components
5. REST Data Sources and Web Credentials
6. Authentication and Authorization Schemes
7. Application Settings
8. External services and database links
9. Database tables and views

One should maintain a dependency list to track which components already exist in the target environment and which ones need to be deployed. This simple step can prevent situations where the application imports successfully but fails when someone opens a particular page/module.

**2\. Keep database deployment scripts separate:**

Exporting an APEX application does not automatically migrate all supporting database objects.

For example:\
\
Application uses the following objects:\
APP_INVOICE_HDR\
APP_CUSTOMER_MASTER\
APP_CUSTOMER_INV_DELIVERY_METHOD_VW\
APP_INVOICE_PAYMENT_PKG\
APP_PAYMENT_ID_SEQ\
\
These objects need to be migrated separately. For larger applications, prefer keeping database scripts organized by object type.\
\
APEX_MIGRATION:

01-TABLES\
02-VIEWS\
03-SEQUENCES\
04-PACKAGES\
05-PROCEDURES\
06-TRIGGERS\
07-SYNONYMS\
08-GRANTS\
09-APEX_APPLICATION

Keeping scripts organized makes it easier to identify migration failures and maintain different application versions.

**3\. Schema ownership and privileges:**

For example, a view owned by the APPUSER schema that reads data from another schema.

Before deploying it, we should check:

If the correct schema owns the view.\
Whether all referenced tables and views exist.\
The required privileges are granted directly to the owner schema.\
Whether synonyms point to the correct database objects.\
The view compiles successfully.

For example:

```sql
CREATE OR REPLACE VIEW appuser.app_customer_view AS
SELECT
    customer_id,
    customer_name,
    customer_status
FROM apps.customer_master;
```

If the required privileges are missing, the view may become invalid. After deployment, check the object status:

```sql
SELECT
    owner,
    object_name,
    object_type,
    status
FROM all_objects
WHERE owner = 'APPUSER'
  AND object_name = 'APP_CUSTOMER_VIEW';
```

If the object is invalid, check the compilation errors:

```sql
SELECT
    line,
    position,
    text
FROM all_errors
WHERE owner = 'APPUSER'
  AND name = 'APP_CUSTOMER_VIEW'
ORDER BY sequence;
```

Resolve these errors before moving on to application-level testing.

**4\. Export the APEX application:**

Once the supporting database objects are ready, the next step is to export the APEX application. We can export an application through the APEX application interface or use SQLcl.

For example:

apex export -application id 100

Use the appropriate export options supported by your installed SQLcl version. Before exporting, make sure the correct application version is available in Development.

**A few things to review before export:**

1. Application ID
2. Supporting Objects
3. Build Options
4. Export preferences
5. Static Application Files
6. Plug-in dependencies

**5\. Review Shared Components before deployment:**

Shared Components needs migration review. It is easy to check on pages, regions, and processes while we overlook configurations that are used throughout the application.

*Some important shared component items:*

Application Items:\
Check whether all required global items exist and whether their values are populated correctly.

Lists and Navigation Menus:\
Make sure menu entries point to valid pages and that the navigation structure is consistent.

List of Values (LOVs):\
Review the SQL queries, return values, and referenced database objects.

Authentication and Authorization:\
Confirm that the target environment uses the expected authentication and access rules.

Application Processes:\
Review application-level PL/SQL processes and make sure their dependencies are available.

Web Credentials and REST Data Sources:\
They need review because their configuration may differ between environments.

**6\. Manage Development, UAT, and Production configurations:**

Development, UAT, and Production generally use different service URLs, credentials, and application settings.

For example:

DEV:\
<https://dev-api.example.com>

UAT:\
<https://uat-api.example.com>

PROD:\
<https://api.example.com>

Hardcoding these values in multiple pages makes future changes difficult. Solutions for this issue:

1. APEX Application Settings
2. APEX Web Credentials
3. Environment-specific configuration tables

**7\. Consider APEX version differences:**

Moving an application between environments and upgrading the APEX platform are two different activities. If the target environment uses a different APEX version, there are the things to consider.

1. Universal Theme
2. Custom CSS and JavaScript
3. Plug-in
4. Deprecated APIs
5. Interactive Grid functionality
6. Authentication configuration
7. REST integration
8. Session State Protection
9. Page rendering and navigation

For example, a CSS selector that worked with an older Universal Theme implementation may behave differently after an upgrade.

**8 Prepare a rollback plan:**

Production deployment never means that everything will work as expected.\
Before starting, keep the previous application version and the database changes for rollback.

Keep the following ready in case a rollback is needed:

1. Previous APEX application export
2. Approved recovery point
3. Previous versions of changed database objects
4. Deployment scripts
5. Configuration details
6. Test results
7. Rollback instructions

Restoring an APEX application export does not automatically reverse database changes or undo transactions performed by external systems.

**Conclusion**

Oracle APEX migration becomes easier when dependencies are identified before deployment.

The application export is only one part of the process. Database objects, schema privileges, Shared Components, security settings, external integrations, and environment-specific configurations all need to be considered.
