ScriptsApr 21, 2026·3 min read

Liquibase — Database Schema Change Management and Migration

An open-source database migration tool that tracks, versions, and deploys schema changes across relational databases using XML, YAML, JSON, or SQL changelogs.

Introduction

Liquibase is a database schema change management tool that brings version control discipline to database migrations. Changes are defined in changelog files using XML, YAML, JSON, or raw SQL, and Liquibase tracks which changesets have been applied via a metadata table. It supports rollback, diff, and documentation generation, making it a core component of database CI/CD pipelines across enterprises.

What Liquibase Does

  • Applies incremental database schema changes from versioned changelog files
  • Tracks applied changesets in a DATABASECHANGELOG metadata table for idempotent runs
  • Supports 50+ databases including PostgreSQL, MySQL, Oracle, SQL Server, and Snowflake
  • Generates rollback SQL for reversing applied changes
  • Diffs two database schemas and produces a changelog to synchronize them

Architecture Overview

Liquibase reads a changelog file containing an ordered list of changesets, each identified by an author and ID. It connects to the target database via JDBC, checks the DATABASECHANGELOG table to determine which changesets are pending, and applies them in order within transactions. Each database platform has a dialect layer that translates abstract change types (createTable, addColumn) into platform-specific DDL. Pre-conditions and contexts allow conditional execution across environments.

Self-Hosting & Configuration

  • Install the CLI via Homebrew, SDKMAN, or download the binary distribution
  • Configure liquibase.properties with JDBC URL, credentials, and changelog path
  • Use --contexts to apply environment-specific changesets (dev, staging, prod)
  • Integrate with Maven, Gradle, or Spring Boot for automated migration at startup
  • Store changelogs in version control alongside application code

Key Features

  • Database-agnostic abstract change types that generate correct DDL per platform
  • Preconditions gate changesets on database state before execution
  • Labels and contexts enable environment-specific migration strategies
  • Built-in diff and snapshot commands for schema comparison and documentation
  • Extensible with custom change types and third-party database extensions

Comparison with Similar Tools

  • Flyway — simpler SQL-first approach; Liquibase offers abstract change types and richer rollback support
  • Atlas — declarative schema-as-code; Liquibase is imperative with ordered changesets
  • Alembic — Python/SQLAlchemy specific; Liquibase is language-agnostic via JDBC
  • dbmate — lightweight CLI for SQL migrations; Liquibase provides enterprise features like preconditions and diff
  • golang-migrate — Go-focused; Liquibase has broader database support and richer change semantics

FAQ

Q: Can I write migrations in plain SQL? A: Yes. Liquibase supports raw SQL changelogs alongside XML, YAML, and JSON formats. You can mix formats within a project.

Q: How does rollback work? A: Liquibase auto-generates rollback SQL for standard change types. For custom SQL changesets, you provide explicit rollback statements in the changeset definition.

Q: Does Liquibase lock the database during migrations? A: Liquibase acquires a row-level lock in the DATABASECHANGELOGLOCK table to prevent concurrent migration runs, but it does not lock application tables.

Q: Can I use Liquibase with CI/CD? A: Yes. The CLI integrates with Jenkins, GitHub Actions, GitLab CI, and any pipeline that can run a Java-based tool. Liquibase also offers a Docker image for containerized pipelines.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets