-
1. Re: Running DB migration prior to jpa initialization
smarlow Dec 20, 2012 4:37 PM (in response to anilarora)Would you package the migration script with the application?
You might want to follow the JPA 2.1 specification which introduces a few different ways to accomplish this (for EE7). See section 9.4 Schema Generation.
-
2. Re: Running DB migration prior to jpa initialization
anilarora Dec 20, 2012 5:07 PM (in response to smarlow)Unfortunately, I must remain on Hibernate 3.6.10 and I don't want to rock the boat on changing that at the moment.
Yes, the classes/script files would be packaged with the application. I'd probably create some deployment descriptor special for this case to make this happen.
-
3. Re: Running DB migration prior to jpa initialization
smarlow Jun 26, 2013 9:31 AM (in response to anilarora)Lately, I'm thinking that a "wildfly.jpa.migration" (or something like that) persistence unit hint, could be used to trigger the database migration before the persistence unit service creates the entity manager factory. When I have time to work on it, I'll associate a git branch with WFLY-1186 for us to use for this feature.
http://stackoverflow.com/questions/11071821/cdi-extension-for-flyway mentions some current solutions that could be used with Hibernate 4.x, in case anyone is interested in trying that now.
With "wildfly.jpa.migration", we could use the http://flywaydb.org project (if available) or the JPA 2.1 schema generation support (see comments in WFLY-1186). Why allow two methods? Because JPA 1.0/2.0 persistence providers don't have the schema generation support and flywaydb is more flexible in other ways (the optional flywaydb java based migration gives more flexibilty).
Scott