Bit of friday fun - just tried searching for Node GString, and Google helpfully suggested...
Did you mean: nude g string
Friday, 19 November 2010
Using Liquibase DropAll Automagically 2
A while back gus posted about how to get liquibase to drop all on application start up. He had to jump through some hoops because dependsOn wasn't working properly. This seems to be OK now so I think the process can be simplified a bit...
Assuming the changelog is specified in grails-app/conf/liquibase/master.xml
resources.groovy
if (config.liquibase.on) {
liquibaseDropAll(LiquibaseDropAll) { bean ->
dataSource = dataSource
changeLog = "classpath:liquibase/master.xml"
bean.initMethod = 'init'
}
liquibase(SpringLiquibase) { bean ->
dataSource = dataSource
changeLog = "classpath:liquibase/master.xml"
bean.dependsOn = ['liquibaseDropAll']
}
}
LiquibaseDropAll.groovy
import liquibase.spring.SpringLiquibase
import org.codehaus.groovy.grails.commons.ConfigurationHolder
class LiquibaseDropAll extends SpringLiquibase {
void init() {
if (ConfigurationHolder.config.liquibase.dropAll) {
super.createLiquibase(dataSource.connection).dropAll()
}
}
}
Disclaimer: I've only just started using it so it may still thow up some gotchas.
Subscribe to:
Posts (Atom)