BigQuery Schema Management using Liquibase (CICD for Databases)
Cloud Track
Samrat Priyadarshi
Cloud Engineer
github.com/SamPriyadarshi
linkedin.com/in/sampriyadarshi
@SamPriyadarshi
Agenda
Why CI/CD for Databases
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:
Even in organizations that have adopted DevOps, manual rework is the norm when it comes to database schema and stored procedure changes. In fact, the faster the application release cycle, the more database professionals had to rework database changes.
Liquibase
Open-source database schema change management solution
Key Concepts
Changeset
A changeset is a unit of change that Liquibase runs on a database. A changeset is uniquely tagged by both an author and an id attribute (author:id), as well as the changelog file path. The id tag is only used as an identifier, it does not direct the order in that changes are run and does not have to be an integer. If you do not know or do not want to save the real author, use a placeholder value such as UNKNOWN. To execute the changeset, you must have both author and id.
Changelog
The changelog file is the source of all Liquibase changes. The changelog includes a sequential list of all database changes (changesets). Liquibase uses this changelog record to audit the database and enforce any changes that are not yet applied to the database. Changelogs can be in XML or JSON or YAML or SQL format and even mixing and matching distinct types of changelogs is also allowed.
DATABASECHANGELOGLOCK table
The DATABASECHANGELOGLOCK table assures that only one instance of Liquibase is running at a time. The DATABASECHANGELOG_ACTIONS table follows the object state and the SQL statements run during the deployment.
DATABASECHANGELOG table
This table is utilized by liquibase to track which changesets have been run. The table tracks each changeset as a row, specified by a combination of the “id”, “author”, and “filename” columns.
There is no primary key on the table. This is to avoid any database-specific constraints on key lengths. The “id”, “author”, and “filename” is unique across every row of the table.
Features
Demo
Q&A
Thank you
github.com/SamPriyadarshi
linkedin.com/in/sampriyadarshi
@SamPriyadarshi