Database deployment is so critical in product development.
An important area in database development is its deployment in various environments. This becomes more critical when there are more than one database servers involved and the database deployment is required to happen at the same time. With increasing manual efforts within traditional database deployments, there are always chances of missing or repeating the deployment steps. The result is inconsistent databases and can cause data loss in extreme cases.
To address such issues with database deployment and schema versioning, there are several tools available in the market. Liquibase is one of these tools with capability of extending the basic functionality.
Liquibase as the database deployment solution
Liquibase is gaining popularity among the database developers for hassle-free database deployment process. The schema versions are maintained within Liquibase, and efficiently enable a fast deployment process. Liquibase supports database deployment for the relational database management systems like Microsoft SQL Server, IBM DB2, Oracle, etc., and also open source database systems like PostgreSQL, MySQL etc.
Liquibase has following capabilities to offer database developers:
- Database schema versioning
- Multi-branch environment
- Database change history tracking
- Rollback changes until a particular tag, date or changelog number
- Performing precondition check
- Support for almost 10 database systems
Liquibase capabilities can be leveraged into a sample deployment action.
Using Liquibase
The deployment process is changeset driven, which includes author and change identification number. The author can be set to “UNKNOWN” if the business does not wish to disclose this information to deployment folks. The changesets or changelogs can store in following formats:
- XML
- JSON
- YAML
- SQL
However, Liquibase extension allows you to use the format of your choice for your changelog file. We have created a POC project using Liquibase for the database deployment on PostgreSQL database instance. In the sample database project in github, we are building a XML type changelog definition file in order to deploy the PostgreSQL database. Also, it depicts how easy it is to use after setting up the changelog as per requirement.
Depending upon the type of database system selected, an appropriate database driver is used to connect and perform the schema “write” operations to the database.
A typical Liquibase workflow
Developers supply the database configurations and changelog definitions. Liquibase does the rest by performing the remaining deployment steps, such as preparing a single database deployment script, utilizing the supplied configuration values to setup the script, connecting to specified database servers and executing the prepared script on correct database instances. Liquibase also catches the runtime errors within database deployment execution and performs rollback routines as specified in the changelog definitions.
Conclusion
With the simplicity of implementing Liquibase for PostgreSQL database, code changes and changelog management, it definitely puts Liquibase way ahead of the other database deployment tools (like flyway, Sequel migration etc.) available in the market.
Try out Liquibase and let me know your thoughts on it!
Valmik Potbhare
Technical Lead at Synerzip