Recently, in my tea talks with my colleagues, Flyway came up. I was curious to experiment with it. According to their official site, Flyway is the version control for your database with many great features.
One of the most important questions before even experimenting is WHY?
Well, my take on this is that Version control is very important when it comes to databases. In many cases, techies develop their in-house version controls or tools to manage schemas and scripts. Bottom-line is that version control is indeed important.
Well, to try Flyway, I would sum it down to 5 easy and quick steps:
- Download Flyway zip folder from here and extract it to your machine.
- Copy this folder path and add it to your Environment Variables. If you are not sure how to add a path to Environment Variable, check here
- In the extracted folder, there will be a conf folder. Under it, update the flyway.conf with database connections.
- Place your database migration scripts under sql folder. This folder will be present under the extracted flyway folder. Note:Please refer this link for the naming conventions for flyway.
- Open your command prompt, and run
flyway migrate. This will run your migrations. In case if you get the error
ERROR: Found non-empty schema(s) [dbo] without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table.In this case run this:
flyway migrate -baselineOnMigrate=true. This command will create a baseline schema version table and data in your db for Flyway
Et voila !
This will run the scripts and update the version in your database.
Flyway supports a no of databases and is worth a try.
There are many more things that can be experimented with it.