Support for database migrations and reverse engineering are two related features that we've scheduled for Grails
1.4/2.0 (see the roadmap wiki page
for the others). The migration support will be based on Liquibase
and there's already a plugin for that
so I started looking at reverse engineering first.
Work progressed faster than I expected (thanks to the features of the Hibernate Tools
library and all of the time I spent digging into its internals for the App Info
plugin) and it didn't depend on any new features in 1.4 (not yet anyway) so I released the plugin
yesterday so users can started using it now. Install it the usual way:
and refer to the documentation
for configuration options.
I tested this with MySQL and Oracle, and other databases that Hibernate supports should work too. There's a tutorial in the documentation that uses MySQL, and you can use the Chinook database
to test with Oracle. I used these settings (in grails-app/conf/Config.groovy) for the Chinook database:
grails.plugin.reveng.defaultSchema = 'CHINOOK'
grails.plugin.reveng.manyToManyBelongsTos = [PLAYLISTTRACK: 'PLAYLIST']
and these datasource settings (in grails-app/conf/DataSource.groovy)
url = 'jdbc:oracle:thin:@localhost:1521:orcl'
driverClassName = 'oracle.jdbc.driver.OracleDriver'
username = 'chinook'
password = 'p4ssw0rd'
dialect = org.hibernate.dialect.Oracle10gDialect
}
Try it out and report any issues on the Grails user mailing list
or in JIRA
under the 'Grails-Reverse-Engineer' component.
One related thing I wanted to point out is that the work to replace HSQLDB with H2
is mostly complete (JIRA issue here
). I'm a big fan of H2 and one of its coolest features is its embedded web-based console
(which works with any database that has a JDBC driver). This is now enabled by default in the development environment and can be enabled in other environments. Accessing data in your development database will be very convenient in 1.4 - just open http://localhost:8080/appname/dbconsole in a browser (JIRA issue here
).
