Managing Schema Migrations with Flyway + CockroachDB

Managing Schema Migrations with Flyway + CockroachDB

If you use a database, at some point you’ll need to modify your schema design. Maybe you need to store new kinds of information. Perhaps you’ll add a field to a table or even need to change a primary key. Regardless of the reason, application requirements tend to change over time. We know how important schema modification is, which is why we’ve built online schema changes and online primary key changes into CockroachDB. 

Over the last year, we’ve realized that many of our customers like using third-party schema migration tools to ease these transitions and provide structure and control over the process. With this in mind, we decided to improve CockroachDB’s compatibility with schema migration tools. We’re pleased to announce that CockroachDB now fully supports the first of these tools, Flyway.

Flyway is a popular schema migration tool that lets developers write migration files in either SQL or Java. Then the tool handles applying these migrations to the database in order. Another benefit of Flyway is that it can be used as a single source of truth of schema across multiple environments. This is helpful when you need to deploy the same set of changes to different databases, such as your development, staging, and production instances.

Our Docs team has written a comprehensive tutorial on how to use Flyway with CockroachDB. Check it out here, and then hop over to the #product-feedback channel of our Community Slack if you have any comments or questions!

Read the CockroachDB + Flyway Tutorial