grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.79k stars 949 forks source link

GRAILS-5890: changes to an entity don't update the database schema #3168

Closed graemerocher closed 9 years ago

graemerocher commented 14 years ago

Original Reporter: tna Environment: Not Specified Version: 1.2.1 Migrated From: http://jira.grails.org/browse/GRAILS-5890

I declared some constraints for an grails domain class String field. When I tried with length:0..32000, it created a varchar(255) column (instead of varchar(32000), which I expected). I found out I have to use "maxSize" or "size" so I declared the constraint like so: maxSize:32000 I set my datasource to update the schema (rather than drop/create), but it didn't appear to do anything when re-runing the application from the (NetBeans 6.8) IDE. I considered declaring this a "bug" since I did set the schema management strategy to "update" and it did not update when I modified the grails domain class, but wasn't sure so I left it as an improvement request.

graemerocher commented 14 years ago

burtbeckwith said: Hibernate's 'update' mode only adds new tables or columns, but won't drop or change existing columns to avoid data loss (even in a case like this where you're widening). To do proper database migrations you need to manage schema changes manually or use a 3rd-party tool like Liquibase.

graemerocher commented 14 years ago

tna said: Swift reply, thanks for clearing it up and especially for the Liquibase tip!