One of the advantages of Grails 2.0 is that you can change domain classes in development without needing to restart the application server. This works, however when I change domain classes I lose all my bootstrap data, which basically defeats the purpose. I'm using the default h2 database.
What is the best way to get around this? Do I have to go to an external DB like Postgres?
The default
DataSource.groovy
in a newly-created Grails 2 app hasThe
create-drop
means the database will be re-created from scratch whenever the application restarts. If you want a database that persists across restarts then change this to something like(i.e. change
create-drop
toupdate
and remove the:mem
from theurl
). However note that not all changes you can make to a domain class can be reflected in the limited schema changes thatupdate
can apply. Adding properties should be OK, but removing properties or making changes to the constraints that affect schema generation may require you to drop and re-create the database anyway (stop the app, delete the devDb files and start it up again).