One area hasn’t benefited from the DevOps movement as much: The database change process. It’s time to bring CI/CD to the database.
Application release technology has come a long way in the past several years. It used to take weeks or even months to release new software. Now that organizations have adopted new workflows and processes, the time it takes to complete a release has been reduced to days and even hours.
Database schema migration
Database schema migrations are an essential task for every software project. There are several different reasons why updates to the database are required, some examples are:
- New features require new attributes in existing tables or entirely new tables
- Bug fixes may lead to changes in names or data types in the database
- Performance issues that require additional indexes in the database
Even in organizations that have adopted DevOps, manual rework is the norm when it comes to database schema and stored procedure changes.1 In fact, the faster the application release cycle, the more database professionals had to rework database changes. 93% of survey respondents reported reworking database changes multiple times for daily or weekly release cycles.1
Before we jump into how Liquibase fits into the CI/CD process, let’s cover what we mean by CI/CD.
What is Continuous Integration (CI)?
Continuous integration (CI) is a process that automates the integration of code changes from multiple developers in a single software project. The CI process hinges on a source code version control system, such as Git (or Github, BitBucket, and many others) or TFS Version Control, coupled with automated processes for code quality tests, syntax style review tools, and more. These processes can be triggered when new code is merged or committed to a shared repository, thus the name “Continuous Integration.”
What is Continuous Deployment (CD)?
Continuous Deployment (CD) is a process that automates testing to validate if code changes are correct, stable and deployable. If so, in a literal CD context, code is automatically deployed to production as soon as these conditions are met.
CI/CD for databases using Liquibase
Implementing end-to-end CI/CD requires all code (including database code) to be checked in to a version control system and be deployed as part of the software release process. Liquibase can help you achieve this.
Each database schema change you make with Liquibase is called a changeset. All changesets are tracked by Liquibase using changelogs. Liquibase allows you to create a trigger that updates the database automatically by pointing to the changelog file. From here, it makes it easy to integrate the process into your overall CI/CD process:
- Push your changeset files to your feature repository
- Create a pull request against the Dev branch
- After peer review and approvals, merge the feature branch with the Dev branch
- The CI/CD implementation configured on the Dev server triggers Liquibase for database updates
- Liquibase automatically executes any new changelog files (and is awesome enough to remember which scripts have already run)