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
Getting Started
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
Migrate
- 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
Clean
- Drops all schemas and recreates the database – BE CAREFUL!!!!!
- mvn flyway:clean
Info
- Gives you the current status of your database
- mvn flyway:info
Validate
- Lets you know what migrations have been applied and are available
- mvn flyway:validate
Baseline
- Allows you to baseline an existing database, and start versioning later updates
- mvn flyway:baseline
Repair
- Repairs the SCHEMA_VERSION table – eg remove failed scripts
- mvn flyway:repair
References
flywaydb.org