

Flyway 3.2 Released – Database Migrations Made Easy - axelfontaine
http://flywaydb.org/blog/flyway-3.2.html

======
mercurial
At work, I introduced the concept of automated migrations (as opposed to
"let's do it by hand" and "stored procedures are a great solution") with
Flyway. It has been a great success, even though the project needed to support
multiple databases, which Flyway does not handle (but its API is easy to work
with).

I'm not entirely sure of what it does with out-of-order migrations (eg,
"master' has migration A,B,C, and "legacy" has had A and C backported - I'm
not sure if Flyway will gracefully apply B on a "legacy" database when
switching it to "master"), and the docs do not seem to mention this use case.

~~~
axelfontaine
It will work as expected if you set the ... (you guessed it) outOfOrder flag
to true.

------
rickette
Flyway pre-1.0 user here (since 2010). It's a really nice and simple tool.

Liquibase, the other major migration tool in Java, offers platform-independent
database migrations but this requires you to write migrations/query's in XML.
Flyway supports plain SQL, much easier for everyone (dev, DBA, etc) involved.

~~~
axelfontaine
It's always great to hear from someone who's been happy with it from its
humble beginnings! Thank you for having been an early adopter!

------
joshpadnick
I've had such positive experiences with FlyWay. It's well-documented, works
across all the JVM-based languages, and now based on the latest packaging, it
looks like it can be easily used in non-Java projects. Great work
@axelfontaine.

~~~
axelfontaine
Feedback truly appreciated Josh :-)

------
nek4life
I've been learning Flyway and so far it seems to work well for applying
handwritten sql scripts. I was hoping it could generate the migration files
for you based on your entity classes, but that doesn't seem to be the case. Is
there any tools for Java that handle both applying migrations and generating
migration files based on your JPA Entity classes?

I've been using Alembic with SQLAlchemy with Python and I really like the
ability to auto generate migrations and then be able to hand tune them if need
be. I'm looking for the same kind of tooling for Java and haven't really been
able to find it yet.

~~~
axelfontaine
While that approach may seem convenient at first, I recommend the exact
opposite for two reasons:

1\. Your data will outlive your application

2\. I strongly prefer contract-first over code-first interfaces between
systems for stability and reliability issues

Following the latter, as the interface of your database towards your
application is the schema, you should absolutely have that being the driving
force and not the entity classes in your language of choice

~~~
nek4life
I watched this video
[https://www.youtube.com/watch?v=vPwWQvvBWEg](https://www.youtube.com/watch?v=vPwWQvvBWEg)
where (I think you?) explained these points in greater detail and I tend to
agree with you that sql first is a very sensible approach.

I'm probably missing something, but is there a configuration with JPA that can
explain the tables that hibernate's expecting based on the Entity classes? I
guess that's where my biggest pain point going from sql first to writing my
classes is getting the tables to validate and map properly. It's been a little
time consuming being new to the ecosystem trying to get my sql (postgres) to
map to JPA Entity classes going in reverse. Going from Entity classes to SQL
you don't have this issue because the tool is writing the SQL for you (not
saying this is the best approach) so without this a tool for debugging
Entities would be handy to get up to speed faster when using Flyway or another
SQL first approach.

------
codeulike
Looks interesting, but to me "database migrations" means something far more
boring and well catered for already (etl tools etc), hence I almoat didn't
bother looking at the site. From a quick perusal I'd call what flyway is doing
more like 'database version management'.

~~~
axelfontaine
You are absolutely correct. The term migrations is something we took over from
the Rails folks who are largely to credit for popularizing this essential
practice:
[http://edgeguides.rubyonrails.org/active_record_migrations.h...](http://edgeguides.rubyonrails.org/active_record_migrations.html)

