Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Do you have a script to easily export schema objects in a multi-app and multi-schema workspace?

Miguel EscamillaFeb 15 2024

I have a 19c ATP database instance in OCI. It has multiple schemas. The single workspace that we have has multiple applications. I would like to be able to automate the exporting of each schema's objects with liquibase. Having one app and one schema is easy, but when you have multiple schemas, then you need to connect to the db multiple times to export the schema objects. Then you need to manage the complexity of knowing what schemas to export/import first so dependencies do not break. Having multiple schemas is a nice principle, but it has brought unwanted complexity into the APEX development.

Here is a script I came up with using dp and 13 schemas and counting but I get compilation warnings after everything is installed

# Recreate the temporary stage directory and change directory to it
if [ -d $TMPDIR/tmp/stage_f$1 ]
then
rm -rf $TMPDIR/tmp/stage_f$1
fi
mkdir -p $TMPDIR/tmp/stage_f$1
cd $TMPDIR/tmp/stage_f$1



# Attempt to create the datapump file directory
sql /nolog <<EOF
set cloudconfig $4
connect $3
CREATE DIRECTORY APEX_BULK_EXPORT AS 'apexexport';
EOF



# Export APEX application and schema to stage directory
sql /nolog <<EOF
set cloudconfig $4
connect $3
!mkdir workspace
cd workspace
apex export -expWorkspace -expMinimal -workspaceId $1
apex export -expFiles -workspaceid $1
cd ..
REM Export apps
!mkdir applications
cd applications
apex export -workspaceid $1 -split -skipExportDate -expOriginalIds -expSupportingObjects Y -expType APPLICATION_SOURCE,READABLE_YAML
cd ..
REM Export database objects
!mkdir database
cd database
dp export -schemas s1,s2,s3...s13  -directory APEX_BULK_EXPORT -version COMPATIBLE
EOF
# Copy Workspace subdirectory to Git Working Area Directory
rsync --delete --recursive $TMPDIR/tmp/stage_f$1/workspace/* $2/workspace
# Delete Workspace subdirectory
rm -rf $TMPDIR/tmp/stage_f$1/workspace
# Copy APEX application export files in the ./fNNN subdirectory to Git Working Area directory
rsync --delete --recursive $TMPDIR/tmp/stage_f$1/applications/* $2/applications
# Remove APEX export files, leaving only Liquibase DB export artifacts
rm -rf $TMPDIR/tmp/stage_f$1/applications
# Copy the Liquibase DB export artifacts to ./database subdir of Git Working Area
rsync --delete --recursive $TMPDIR/tmp/stage_f$1/database/* $2/database
# Delete Database subdirectory
rm -rf $TMPDIR/tmp/stage_f$1/database
# Change directory to the Git Workarea
Comments
Post Details
Added on Feb 15 2024
0 comments
582 views