flywaydb.org is a database migration and versioning tool. It addresses the common problem that while we version software, we often overlook versioning databases.
How Flyway works
Flyway creates a version table (default – schema_version) – if it doesnt find it it creates it. This table is then used as a reference point for all scripts run against the databases
I’m not covering how to get started with flywaydb because the flywaydb website contains instructions covering command line, API, maven, gradle, ant and sbt
- Core function of flywaydb. Its operation checks for a SCHEMA_VERSION table, and if it doesnt find one it creates one. It will then upgrade the database if necessary
- mvn flyway:migrate
- Drops all schemas and recreates the database – BE CAREFUL!!!!!
- mvn flyway:clean
- Gives you the current status of your database
- mvn flyway:info
- Lets you know what migrations have been applied and are available
- mvn flyway:validate
- Allows you to baseline an existing database, and start versioning later updates
- mvn flyway:baseline
- Repairs the SCHEMA_VERSION table – eg remove failed scripts
- mvn flyway:repair