Marc Rufer 18 Apr 2015 database migration Flyway maven development
After reading a blog post about the database migration tool Flyway on jaxenter I decided to play around with it in the context of a little sample project. The sample project shows the usage of the flyway maven plugin in combination with a h2 database.
A short introduction about database migrations can be found here. To get some basic information about Flyway and how it works have a look at How Flyway works @Flywaydb.org.
For more details have a look at the Flyway documentation
To set up the sample project I had a look into the Get started with maven guide. With the information provided there the setup was straight forward. The configuration of the maven plugin is pretty intelligible and the configuration tags are documented well.
Below you can see the pom-file of my sample project
The database migration files by default have to follow the pattern V{VERSION_NUMBER}_{NAME_OF_THE_FILE}.sql
and have to be placed in the migration directory src/main/resources/db/migration
.
The sources of the sample project can be found on my GitHub-Account.
Spring boot supports flyway database migrations by running them automatically on startup. For more information have a look at the Spring boot documentation.
The configuration of the maven plugin was very straight forward and the plugin worked well for my little sample. On the flyway website you can find some get started tutorials for command line, java API, Maven, Gradle, Ant and SBT. These tutorials are good starting point for everybody who wants to check out the basic functionalities of Flyway.
Furthermore the flyway website provides a lot of information around flyway, which are easy to find thanks to a clear structure.