Including Grails plugin migrations in the changelog of the application

Viewed 758

I am developing a modular application with Grails 2.x and I would like to organize our database migrations in a way that every plugin/module hosts their own migrations in their grails-app/migrations folder. (as opposed to putting all migrations into the migrations folder of the composing application project)

The composing application project itself normally doesn't have any migrations since these are stored in the plugins.

Is it possible to build a "master" changelog in the application project and only reference the plugin migration files in the proper order? This way I could have a very clean and migration system which handles plugin dependency problems as well (I place the plugin migration files references in the order which respects the plugin dependencies, which may change over time, so ordering of the migrations can be fairly complex).

By default the Database Migrations plugin doesn't seem to check/execute plugin migrations at all (inline plugins in my case). The docs don't say anything about this scenario, they concentrate on the simple, non-modular development workflow.

I have seen a solved issue with the DB Migrations plugin that somehow allows running migration files outside of the migrations directory of the app but I assume that would use some kind of hardcoded relative/absolute paths which would not be very elegant.

The most elegant solution would be if I could also specify the plugin for each migration "include" statement so my master changelog would look like this.

databaseChangeLog = {
  include plugin:'core'       ,file:'000-initial.groovy'
  include plugin:'accounting' ,file:'000-initial.groovy'
  include plugin:'core'       ,file:'001-drop-constr-XXX.groovy'
  include plugin:'accounting' ,file:'001-add-col-yyy-to-posting-table.groovy'
}

Is it possible to implement something similar with the current Database Migrations Plugin?

Any help/idea is appreciated.

3 Answers
Related