views:

25

answers:

1

I'd like to make my Bootstrap dependant on the createdb property in the grails DataSource.groovy file. When the setting is 'create', new Master Data should be generated, if the setting is 'update', none.

I've found GrailsDataSource in the Grails API which also has a method getCreateDb, but I don't know how to access it from the Bootstrap for the respective Bootstrap environment.

+1  A: 

The easiest way is probably to just check the value of dbCreate from the config, like so:

import org.codehaus.groovy.grails.commons.ApplicationHolder

if (ApplicationHolder.application.config.dataSource.dbCreate == "create") {
    ...do create stuff...
} else if (ApplicationHolder.application.config.dataSource.dbCreate == "update") {
    ...do update stuff...
}
ataylor
Exactly what I've been looking for, thank you!
werner5471