Liquibase

liquibase

Consider a scenario, currently, your application is using a Relational database, but management has decided to migrate to a NoSQL database, now All DDL and DML queries of all the database tables have to be written and run on a new NoSQL database.

or another scenario, with each new feature release, some new tables are created or changes in existing tables are required. the only way to make changes in the production database is to write DDL and DML SQL queries and provide them to the database team, who will run on production, and then only the application can be deployed.

If application deployment fails, then the application state needs to be reverted back to the previous state. reverting application code is very easy with the help of git commit or branch, but reverting the database to the previous state is very tricky and error-prone, each DDL and DML query has to be observed and a new revert query must be written.

What is Liquibase

Liquibase, an open-source library, tries to address all these issues with the git commit way. each database change state is saved in a change log file with a version. 
changelog supports SQL JSON and YAML as well but XML is more preferred due to readability.

Each change log version stores the state of the database including naming conventions, grants & revokes, and rollback scripts, with the help of the changelog version id, the database can be easily reverted back to the previous state.
Liquibase compares the current state of the database with the changelog file and only makes changes that are not available in the database.
change log file keeps reverting and rolling back for each database state change log, which can be executed automatically if the update fails or manually as well as per requirement.
These changelog files are database agnostic, hence changes made for a type of database can easily be migrated to other databases smoothly. Liquibase supports most of the popular databases including MySQL, Oracle, DB2, and PostgreSQL.

Why should I use Liquibase?

Liquibase has been downloaded over 100 million times. and supports a wide range of databases, a few of which are as below.

  • DataBricks
  • SingleStoreDB
  • MongoDB Pro Extension
  • MongoDB Atlas Pro Extension
  • Azure Cosmos DB
  • Apache Cassandra
  • Amazon Redshift
  • Apache Derby
  • AWS Aurora - MySQL
  • AWS Aurora for PostgreSQL
  • AWS RDS - MariaDB
  • AWS RDS - Microsoft SQL Server
  • AWS RDS - MySQL
  • AWS RDS - Oracle Database
  • AWS RDS - PostgreSQL
  • Azure Database - PostgreSQL - Flexible Server
  • Azure Database - PostgreSQL - Single Server
  • Azure Database for MySQL
  • ClickHouse
  • CockroachDB
  • EnterpriseDB
  • Firebird RDBMS
  • Google BigQuery
  • Google Cloud SQL - MSSQL
  • Google Cloud SQL - MySQL
  • Google Cloud SQL - PostgreSQL
  • Greenplum Database
  • H2 Database Engine
  • HarperDB
  • HyperSQL (HSQLDB)
  • IBM DB2 for i
  • IBM Db2 for Z
  • IBM DB2 LUW
  • IBM Informix
  • Ingres
  • InterSystems Caché
  • MariaDB Server
  • MariaDB SkySQL
  • Microsoft Azure SQL Database
  • Microsoft Azure SQL Managed Instance
  • Microsoft SQL Server
  • MongoDB Community Extension
  • MySQL Server
  • Neo4j Graph Database
  • Oracle Autonomous Database
  • Oracle Database
  • Percona Distribution for MySQL
  • Percona XtraDB Cluster
  • PostgreSQL
  • SAP HANA
  • SAP MaxDB
  • SAP SQL Anywhere
  • Snowflake
  • SQLite
  • Sybase (Enterprise/ASE - now SAP ASE)
  • Teradata Database
  • Vertica
  • VMware vFabric SQLFire
  • YugabyteDB

Liquibase vs Flyway

Liquibase and Flyway are two leading open-source-based tools based on Martin Fowler’s Evolutionary Database available for database version control, both provide options for versioning, deploying, and tracking database changes.
 

Features Flyway Liquibase
Works with both relational & NoSQL database types no yes
Provides a snapshot of the current state of your database no yes
Compares the state of two databases to detect potential malicious code no yes
Allows rollbacks to undo a database change Paid yes
Targets (cherry picks) a change or set of changes to roll back Paid Paid
Validates database code against predefined rules set by DBAs on-demand or in automation     no yes
Provides a dashboard view into each database change in your pipeline no yes
Measures & provides database DevOps metrics for your pipeline no yes
Works with stored logic no yes
Defining changes SQL SQL XML JSON YAML
Java-based migrations yes no
Dry runs Paid yes
Preconditions no yes
Selective deployments Many Files One File
Manage the order of changes Hard Easy

 

follow us on