Flyway 3.2 Released – Database Migrations Made Easy
flywaydb.org
flywaydb.org
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.
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.
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.
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
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.
It allows you to write your domain classes in a Groovy DSL, called GORM http://grails.github.io/grails-doc/latest/guide/GORM.html and generate SQL and SQL migrations as you change your classes.
Here's the Getting Started page from the documentation http://grails-plugins.github.io/grails-database-migration/do...
There is a standalone GORM that allows you to use the Groovy DSL without Grails, I'm not sure how the Migration plugin could be made to work with that.