Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Cloud Spanner Adds Support for Liquibase

Cloud Spanner Adds Support for Liquibase

This item in japanese

Google Cloud has recently added support for Liquibase on Cloud Spanner. The new extension allows developers to use the open-source database library to manage and automate schema changes for the globally distributed SQL database on Google Cloud.

Introduced in 2017, Cloud Spanner is a globally distributed, scalable database service on the Google Cloud Platform that provides RDBMS solutions without sharding or clustering, and offers horizontal scaling but not ANSI SQL compliance.

Started in 2006 by Nathan Voxland and distributed under Apache License 2.0, Liquibase is an open-source database-independent library for tracking, managing and applying database schema changes. Supporting SQL, XML, JSON and YAML, Liquibase stores all the changes to the database in changelog files, automatically creating DatabaseChangeLog and DatabaseChangeLogLock tables to manage database schema changes. The database library provides features such as flexible schema change, repeatable migrations, ability to create changelog to generate an existing database and rollback functionalities, such as rollback of the last N changes or rollback to a particular date and time.

Written in Java and currently in beta, the new Liquibase extension for Cloud Spanner covers most of the DDL and DML commands supporting supports the following operations: createTable, dropTable, addColumn, modifyDataType, addNotNullConstraint, dropColumn, createIndex, dropIndex, addForeignKeyConstraint, dropForeignKeyConstraint, dropAllForeignKeyConstraints, addLookupTable, insert, update, loadData, and loadUpdateData.

The extension provides an example changelog.yaml file that demonstrates a changelog applied to Spanner using the Liquibase CLI and helps applying Liquibase best practices on Cloud Spanner.

Among the current limitations, there are unsupported Spanner features, such as views and stored procedures, and DML limits for the number of rows affected during DML, with the recommendation to use partitioned DML. Using the Spanner JDBC driver, this can be configured using the AUTOCOMMIT_DML_MODE.

Liquibase is not the only open source database version control tool currently supported by Cloud Spanner. As Pritam Shah, director of engineering at Google Cloud Platform, points out:

Cloud Spanner now lets you track, version, deploy, and audit database schema changes using Flyway or Liquibase.

Conversely, Cloud Spanner is not the only managed cloud service supported by Liquibase. While the library supports a variety of databases including Firebird, Snowflake and SQLite, most of the cloud managed databases are either MySQL and PostgreSQL compatible and supported natively using their JDBC drivers, with the type name in LIquibase matching the compatibility mode. For example, for Amazon Aurora, the type name must be either mysql or postgres, while for Amazon RDS it could be mariadb, mysql, mssql, oracle or postgresql.

Rate this Article