--- layout: blog subtitle: "Flyway 3.0: Hello Android!" permalink: /blog/flyway-3.0-android.html ---
Today is birthday time! This blog turns one and Flyway turns 4! And to celebrate we are releasing our next major version: Flyway 3.0.
The hightlights of this major release are:
Flyway tries very hard to stay compatible between versions. But as all major versions go, this one marks a transition. We are leaving old things behind for a brighter future ahead.
The transition from Google Code to flywaydb.org and Github is now complete.
Say goodbye to the old groupId and package name
com.googlecode.flyway
, and welcome org.flywaydb!
Simply update these and you should be good to go!
It's spring time and we have a major release, so it's time to prune some old cruft. In this release we removed:
Flyway 3.0 brings solid database migrations to the Android platform. And it does so in a comprehensive way.
We started with SQLite support. Flyway now works with SQLite 3.7.2 and newer both on Android (4.0 and up) with the SQLDroid Jdbc driver and all the other platforms with the Xerial Jdbc driver.
We then integrated the Android logging system and made sure the classpath scanning works flawlessly too.
Start by adding the SQLDroid driver jar to the
libs directory
Then inside your main activity add this:
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.android.ContextHolder;
import android.database.sqlite.SQLiteDatabase;
SQLiteDatabase db = openOrCreateDatabase("...", 0, null);
ContextHolder.setContext(this);
Flyway flyway = new Flyway();
flyway.setDataSource("jdbc:sqlite:" + db.getPath(), "", "");
flyway.migrate();
Now add your migrations to the assests/db/migration directory and you're done!
P.S.: And yes, we support Java-based migrations too!
Flyway has had MySQL support since 2010. We now built onto that foundation and added MariaDB support, including full support for the MariaDB Jdbc driver.
Users have been asking to be able to integrate more deeply with Flyway for a long time. We finally believe the core is now stable enough to open it up for extension in a way we can support for the future.
The first part we are opening up is lifecycle callbacks. You are now able to hook into all aspects of the Flyway lifecycle. This allows to perform whatever action you what when you want. This could be granting rights to all tables after all migrations complete, recompiling procedures, or whatever you need. You now get handed a connection within a transaction and you can use it to your liking. All you have to do is:
Flyway.setCallbacks(...)The second part we are opening up is migration resolvers. This is for people who need more than the standard SQL and Java migrations. It allows you to resolve and execute migrations in any way you want. This could be reading test data from csv files, integrating with version control for stored procedures, or simply having the possibility to execute some statement outside of a transaction (very useful when you need it).
To get started with this:
Flyway.setResolvers(...)And voilĂ !
These two extension points represent the beginning. We are extremely curious as to what extensions the community will come up with. We will keep a close eye on them and integrate some of the best ones in future releases.
You can also expect stronger build tool integration for these extensions in the future, so that you won't have to write Java code anymore to enjoy them.
Stability and reliability are always our top priority and this release is no exception. It packs a ton of fixes and small improvements across the board. You can find all the details are in the release notes.
Thank you to everyone who reported issues and sent in pull requests. Special thanks to Dan Bunker for the lifecycle callbacks.
Enjoy the release and get it while it's hot!
All users are encouraged to upgrade.
Feel free to share, tweet, post or comment in any way you like.