Using Liquibase with Oracle ATP & ADW
The purpose of this document is to guide you through the process of creating a new Liquibase project with an Oracle Autonomous Transaction Processing (ATP) or Autonomous Data Warehouse (ADW) database.
In this tutorial, you will generate an example project and follow the instructions to apply and learn concepts associated with creating new Liquibase projects with Oracle ATP or ADW.
Note: This example assumes that you have created an Oracle Free tier ATP or ADW Database via the Oracle Cloud web console and that you have created an Access Control List during provision with your IP address.
For more information about provisioning the Oracle Autonomous Database Processing or Autonomous Data warehouse via the Oracle Cloud web console, please see Oracle ATP and ADW related links at the bottom of this page.
- If you have not installed the latest version of Liquibase, navigate to https://www.liquibase.org/download to install the software application.
- Ensure the
liquibase.batfile's path is set to a location in the
- Navigate to https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html and download the
ojdbcdriver jar file for Oracle database.
- Download Wallet.
To Download and install Wallet:
- Log in to your Oracle Cloud account > Select Autonomous Transaction Processing/Data Warehouse > click on autonomous database link > DB Connection > Download Wallet.
- Enter a password for the Wallet and download the
- Record the Wallet password somewhere safe. For this example, let's call this password
- Unzip the Wallet and place it somewhere safe in your file system.
- Navigate to the wallet folder and edit the
ojdbc.propertiesfile with the following:
- Comment out the
javax.net.ssl.trustStorePasswordto the wallet password in step 3.
javax.net.ssl.keyStorePasswordto the wallet password in step 3.
- Comment out the
In the wallet folder open the
sqlnet.ora and make sure that
You are now ready to start the tutorial!
To create a Liquibase project with an Oracle ATP or ADW database, begin with the following steps:
- Create a new project folder and name it
- Place the
ojdbcjar driver file in the
- In your LiquibaseATP-ADW folder, create an empty text file.
- Rename the text file to
Note: changelog files contain a sequence of changesets, each of which make small changes to the structure of your database. Instead of creating an empty changelog file in step 3, you can also use an existing database to generate a changelog. For more information see the changelog topic.
Step One: Update your changelog
In this tutorial, you will need to modify your changelog by adding a template.
To add this changelog template:
- Open the
- Update the changelog file with the following code snippet, then save your file:
Step Two: Create a
- In your LiquibaseATP-ADW folder create a new text file.
- Rename the text file to
- Edit the
liquibase.propertiesfile to add the following properties:
Note: In this properties file example, the driver jar file is
ojdbc8.jarunder the classpath: property. Please rename it to match the one that you have previously downloaded accordingly.
For Windows OS Users
If you are on a Windows machine, please also make the
TNS_ADMIN path to your wallet folder with double dashes in the URL property. Example:
Step Three: Add your changesets
Now we will manually add a changeset to the changelog file. Remember, when adding changesets, they are uniquely identified by author and id attributes. Liquibase attempts to execute each changeset in a transaction that is committed at the end.
To add your changesets:
- In the
myChangeLog.xmlfile line 9 to 20 add a new department by creating a table changeset as follows:
Note: This create table changeset is XML format. The corresponding SQL statement should look like the following:
- Open the command prompt. Navigate to the
- Run the following command:
- Sign in to your Oracle Cloud account and navigate to Autonomous Database or Data Warehouse.
- Click on tools tab > Open SQL Developer Web and enter your Database username and password.
You should see a new department table added to the database.
You should also see two more tables:
- DATABASECHANGELOG tracking table – This table keeps a record of all the changesets that were deployed. This way, the next time you deploy your changelog, your changesets are compared to the DATABASECHANGELOG tracking table and only new changesets not found in the DATABASECHANGELOG will be deployed. A new row will also be created in your DATABASECHANGELOG tracking table with the changeset information you just deployed.
For this example:
- DATABASECHANGELOGLOCK – This table is used internally by Liquibase to manage access to the changelog table during deployment.