I would like to add a field to an existing domain class. I do not want to lose my view files however as I know will happen if i run generate-all. Is there another way I can update the mapping etc?
just declare it:
class MyDomain {
String newField;
}
Should be all you need to do.
There are a couple of ways to do this.
If you have not modified your generated views too much and are using version control, you could allow grails to overwrite your views and then merge the changes to the new templates with what is in version control.
If you have modified your generated views, you could just answer no to the prompt for overwriting the views. If you are only adding a new field, changing a field name or something simple like that, modifying the view templates should be pretty straight forward to do manually.
You would deal with any possible changes to the Controllers in the same way.
I think this is a common concern.
This is not a direct solution to your problem, but this is what I do and works very well for me.
I never make direct modifications to the grails scaffolded artifacts (views and controllers)
I keep my production views/controllers separate from the scaffolded artifacts; through I use the scaffolded as the starting point of my application controllers and views.
If there are changes to the domain model, I re-generate the views and copy-paste (wherever possible) from scaffolded artifacts to hand-coded artifacts.
At some point, I either delete all the scaffolded artifacts from the app or just protect access to them.
Hope this helps.