Skip to content
Database migrations with Flyway
Version control/management of updates
Using Flyway for database version control
- Use timestamp to tag migration. Makes it easier to manage especially if you're going to be in a multi-developer environment
- Use git to track migrations - flyway notices if a migration file changes and causes issues
Setting up flyway
- Sqlite jdbc driver - xerial/sqlite-jdbc - for prototyping
- Postgresql JDBC Driver - Postgresql
- Flyway ant library - Flyway Ant
- Directory Structure
- flyway/ # Flyway ant
- Using the serial date for tracking migrations -
Using ant to run migrations
- Using SDKMAN to manage ant - sdkman | Ant
- Added Ant contrib jar
- Libs used
- ant-contrib-1.0b3.jar -- ant contrib jar - (Ant contrib task)[http://central.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar]
- postgresql-9.4.1212.jar -- Postgresql
- flyway - has the flyway core and ant libraries -- Flyway Ant
- build.xml in db library
Deleting a migration.
Can't delete a migration, only repair it.
- Comment out the commands in the migration mistake you are eliminating.
ant repair to fix the checksums for the migrations
- Validate the current tatus
- Flyway should be back to the status it is suppose to be in.