I have a Grails project in which the development environment uses an in-memory H2 database:
dataSource {
dbCreate = "create"
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
I can run the app (using run-app) and put some stuff in the database (eg. using a scaffolded controller). Now, if I make a change to a source file, Grails detects the change, recompiles the class, and... clears the database!
I tried to use file
instead of mem
in the JDBC URL, but the behavior is the same. The only way I have found to avoid this is to set dbCreate
to "update"
instead of "create"
, but this is not what I want either, because I load a fixture in the application’s BootStrap
, so when the application is restarted I end up with multiple copies of my fixture.
So the question is: How can I prevent Grails from recreating the database when it recompiles a class — or, alternatively, to reload my fixture whenever it clears the database?