Newsletters




Oracle Database Deployment Automation Using Liquibase Open-Source Solution

Page 1 of 2 next >>

Oracle database administrators (DBAs) face significant challenges in managing consistency, efficient collaboration, and complex database schema changes across multiple environments. Manual processes for schema updates can be error-prone, time-consuming, and difficult to coordinate across large teams. Downtime and data inconsistencies are two risks organizations face in this situation. To address this, DBA teams can use reliable database schema management tools such as Liquibase. 

What is Liquibase?

Liquibase, launched in 2006, is an open-source database schema management tool written in Java, was designed to simplify the tracking of database changes, particularly in agile software development settings. It offers developers and DBAs a platform-independent solution for tracking, managing, and implementing database changes, with a key feature being its support for database version control.

Oracle DBAs gain a powerful solution to streamline schema versioning, provide continuous integration and delivery, and reduce the risk of human error.

Adopting Liquibase can improve the efficiency, reliability, and agility of your workflow, allowing you to focus on more strategic tasks. 

Benefits of Liquibase for Oracle Database Deployment Automation

  • Database Version Control: Track and manage modifications over time.
  • Database Rollback: Get a safety net in the event of CI/CD pipeline deployment errors.
  • Cross-Platform Compatibility: Use the databases you want for all of your environments in CI/CD workflows. 
  • Declarative Database Changes: Improve readability and comprehension compared to imperative scripts. 
  • Collaboration and Teamwork: Use concurrent work capabilities on database changes to minimize CI/CD conflicts. 
  • CI/CD Integration: Ensure consistent and reliable schema changes across your environments. 

Important Liquibase Terms 

Changelogs

Liquibase uses changelog files in SQL, XML, YAML, or JSON formats to list database changes in sequential order. 

Here’s an example of a changelog in XML:

Changesets

A database change is called a changeset. You can apply many changeset types to a database,  such as creating a table, adding a primary key, or creating a package.

For example, the file departments_table.sql is a changelog with two changesets:

  • Line 1 – liquibase formatted sql is a syntax you need to add at the beginning of every new SQL changelog. This is how Liquibase identifies changelogs.
  • Lines 2 and 13 – Those lines are identifiers that uniquely describe every changeset.
  • Pretius – changeset author
  • departments_table and add_col_description – unique changeset identifiers (id)
  • Lines 3 and 14 – These are comments. You are not required to include comments. 

Tracking Tables

Liquibase uses the DATABASECHANGELOG table to track which changesets have been run. If the table does not exist in the database, Liquibase creates one automatically.

Liquibase will also create the DATABASECHANGELOGLOCK table. This table creates locks to avoid simultaneous Liquibase runs to your database. 

sqlFile

The sqlFile Change Type allows you to specify SQL statements in an external file.

Oracle Verified Database Versions Compatible with Liquibase

Oracle Database:

  • 23c
  • 21c
  • 19c
  • 12.2
AWS RDS for Oracle Database:
  • 21c
  • 19c

Liquibase Prerequisites

  • Liquibase installed on your machine.
  • Java installed on your machine. Note: If you used Liquibase’s installer, this is automatically included.
  • Set up a new Liquibase project folder and organize your changelogs.

Configure Your Database Connection

Specify the database URL in the liquibase.properties file (defaults file), along with any other properties you need to choose default values for. Liquibase does not parse the URL. You have the option to specify the full database connection string or the URL with your database’s standard connection format. 

Property File Variable Declaration Example

  • #### Enter the target database 'url' information  ####

liquibase.command.url=jdbc:h2:tcp://localhost:9090/mem:dev

  • # Enter the username for your target database.

liquibase.command.username: dbuser

  • # Enter the password for your target database.

liquibase.command.password: letmein

Oracle Server

url: jdbc:oracle:thin:@<host>:<port>/<service_name>

Oracle on AWS RDS

url: jdbc:oracle:thin:@<endpoint>:<port>:<sid>

Page 1 of 2 next >>

Sponsors