In Grails, how can plain SQL/DDL be used to create / drop tables in the same manner they would be if one were using GORM / ORM?
For example, when using GORM / ORM, the tables used for persistence are regularly created/dropped, and inserted into, during the runtime of Integration Tests, and execution of the application.
I know there is a way to do this using just Groovy as shown in the example named “Advanced Usage” here, but I’m looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.
As far as I know, there is no such support built-into Grails, so you’ll have to write it yourself. Luckily it shouldn’t be too difficult. Here’s an implementation plan:
Bootstrap.groovy, dependency-inject the DataSource Spring beaninitclosure ofBootstrap.groovyuse the DataSource to get a Connection to the DBdestroyclosure ofBootstrap.groovy, drop the database