June 12, 2024

Git for the database: DevOps-aligned database migrations

See Liquibase in Action

Accelerate database changes, reduce failures, and enforce governance across your pipelines.

Watch a Demo

Table of contents

Git is an amazing tool for collaboration — developers can work together to build better software faster. However, the usual git workflow neglects the database. 

A few years ago, almost 60% of application releases required changes to the database. That percentage has undoubtedly grown as applications and user experiences become even more data-heavy – and the uses for data itself have grown exponentially since that 2019 survey. 

Despite this, so many application development teams still exclude database changes from the rest of the automated DevOps pipeline. That means not only are database deployments slow and out of sync, they’re:

  • Manually managed, reviewed, and tested – carrying a high risk of error or security concern
  • Hard to track or not tracked at all – so it’s hard to know who made the change or why
  • Not versioned – so trying to roll back to a stable state becomes futile
  • Misaligned across environments – making it easy for various stages to drift, introduce errors, and complicate testing

Liquibase brings git (GitOps) to the database so you can easily version containerized databases, share changes with team members, store versions in remote locations, and tag versions.

Here’s what that means for the quality, efficiency, and success of your database schema migrations. But first, let’s dive into git as a foundational DevOps concept to understand how it extends to database change management

What is git?

Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple developers to work on a project simultaneously without interfering with each other’s work. Git keeps track of changes made to files and enables developers to revert to previous versions if needed. 

By branching and merging via git, teams work on different features simultaneously and later merge their work seamlessly. This enables a distributed development environment in which every developer has a local copy of the repository, including its history, which enables work to be done offline and provides redundancy. Git also records changes to the files in a project over time (version control), which helps track progress and revert to earlier states if necessary.

The “vanilla” git workflow

The standard git workflow is simple. A developer can git init to create a local repository. Next, after making changes, git commit creates a local version. Then, the developer pushes to a remote branch using git push. Finally, another developer can git pull to see the new code updates.

Git is widely used in the software development industry, forming the backbone of many DevOps practices by enabling continuous integration and continuous deployment (CI/CD).

So why hasn’t it made it to the data store and change pipeline?

What is git for the database?

“Git for the database” refers to the practice of tracking all changes to databases using files committed to source control, much like how application code changes are managed. This approach brings the benefits of database version control to database change management, ensuring that every change is documented and can be traced back to a specific point in time. A clear history of modifications allows teams to know exactly what changes were made, when, and by whom. This level of transparency and accountability is crucial for maintaining the integrity and reliability of databases as they change. 

Another significant advantage is that these changes can be applied automatically through a DevOps CI/CD pipeline. This automation reduces the need for individuals to have direct access to sensitive data, enhancing security and efficiency. Changes can be deployed consistently and reliably across different environments without manual intervention. They can also be easily rolled back without delay or disruption. 

Plus, the source and ownership of changes are easily identifiable, enhancing traceability and observability in ways that support faster remediation and ongoing process optimizations. 

Why high-performing teams embrace git for the database

Using git for the database aligns the critical data store pipelines with modern DevOps practices, making database change management a first-class citizen in development and deployment workflows. 

By enabling version control for database changes, teams ensure that all changes are tracked, managed, and easily reversible. Just as no team would even dream of not versioning their applications, applying git principles to database workflows ensures consistent versioning and management of changes. That supports two of the most crucial aspects of these databases:

  • Integrity
  • Reliability

Enacting git for the database also enhances security and compliance, since it eliminates the need for direct human intervention, reducing the risks of human error and dangerous access. With every change recorded in git, accountability, auditability, and traceability improve, so compliance with data regulations and security protocols is easier to achieve. 

Git for databases best practices

To effectively manage databases with git, it’s crucial to follow certain best practices. One key practice is using tags to manage versioning. For example, creating a “golden” database to standardize testing and use in specific deployments ensures consistency across environments. Tags help track and identify specific versions of your database, making it easier to manage updates and rollbacks.

Making small and incremental changes is another recommended practice. Aim for a short lead time — the time between opening and merging a pull request (PR). Smaller PRs are generally quicker to review and deploy, although very small PRs can also lag. For optimal review times, keep total changes between 50-100 lines across all assets. Avoid massive database changes, too, as failures can be challenging to revert and can significantly disrupt operations. Git embraces the standard DevOps principle of smaller, more frequent releases. 

How these changes are applied is also a crucial decision. A state-based approach to change derivation can seem quick and easy, but can miss crucial elements and lead to downstream conflicts. A migration-based approach, on the other hand, uses a more atomic and iterative approach to bundle collections of small changes and merge them without disrupting other teams’ changes. 

Finally, integration is the make-or-break moment. Bringing the git for database change management workflow into the automated CI/CD pipeline unlocks the practice’s full value. 

Git vs GitOps

Git is a distributed version control system used to track changes in code and facilitate collaboration among developers. GitOps, on the other hand, is a practice that uses Git repositories as the single source of truth for managing infrastructure and application deployments, automating the process to ensure that the live environment matches the desired state defined in Git. Essentially, Git focuses on version control for code, while GitOps extends this to automate and manage infrastructure and deployments.

That’s where Liquibase comes in – providing an automated, migration-based approach to git, or rather GitOps, for the database.  

Liquibase enables git for databases through GitOps

Liquibase does more than just bring git to databases. It extends git automation by integrating GitOps principles into database change management as part of a complete database DevOps solution. It goes beyond version control to enhance collaboration, consistency, and traceability while connecting the CI/CD pipeline through to the database layer. 

Liquibase employs a control file, or changelog, to define and sequence changes, which can be stored and versioned in git. This allows for automated, scripted application of changes across database environments, maintaining the defined state and enhancing security and compliance. If any unexpected changes are present, Liquibase can alert teams to investigate the database drift

By aligning database changes with GitOps, Liquibase minimizes human intervention, reduces errors, and ensures reliable, easily auditable database deployments.

Learn how to bring database changes into a GitOps framework with Liquibase. 

Share on:

See Liquibase in Action

Accelerate database changes, reduce failures, and enforce governance across your pipelines.

Watch a Demo