I am using Grails 2.4.3 and the database-migration:1.4.0 plugin.
I have created a simple Domain class called Mod. I am able to create the groovy based changelog using dbm-generate-gorm-changelog changelog.groovy
. This correctly generates the file. I then execute dbm-update
which reports:
|Starting dbm-update for database sa @ jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000
|Finished dbm-update
However, there are no table created in the database and running dvm-status
returns:
|Starting dbm-status for database sa @ jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
1 change sets have not been applied to SA@jdbc:h2:mem:devDb
changelog.groovy::1413897188349-1::clarkrichey (generated)
|Finished dbm-status
My development environment configuration from DataSource.groovy is as follows:
development {
dataSource {
// dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
The issue centers around the fact you are using an in-memory instance of h2. Thus, nothing is saved between application launches. If you want a persistent database then change your url to use a file based instance.
development {
dataSource {
dbCreate = "none" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:file:/path/to/save/to/devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}