Overview

Flyway is a database migration tool. It provides a system for recreating/migrating a database consistently and keeping track of the past and present state of the database. It stores this meta data in a table called `schema_version`.

We will be using the command line execution mode.

You can find more about it at https://flywaydb.org/ .

Commands

These are all of the commands that are available.

Most common commands that people run

Configurations

Flyway will automatically look for a file called flyway.conf. This file is usually in `<install-dir>/conf/flyway.conf`

Command-line parameters override Configuration files.

Most notable ones are:

Conventions

Flyway has a strict naming convention when it comes to deciding when/how to run SQL migrations. The name of the SQL file matters!

Here is a sample file name `V1_0001__create_db.psql` the structure being prefixVERSIONseparatorDESCRIPTIONsuffix.

If the SQL file in question is not formatted as such, Flyway will not pick up the file to run.

Contributing

DMC has two distinct Flyway migrations

In our SQL directory we have a core and data sub directory; please put your migrations in the appropriate place.

In order to run core or data, you will need to point to the appropriate flyway.conf file.

For example standing up a brand new DB with test data you would run the following:


  1. ./flyway clean migrate info -configFile=conf/core/flyway.conf

  2. ./flyway migrate info -configFile=conf/data/flyway.conf