Search code examples
grailsconstraintsgrails-orm

Update constraints in Database - Grails 3.2.2


I had a class with a String field and now I have added a new constraint:

foo(maxSize: 30)

In my dataSource I have this value:

dbCreate: update

And when I run the app the maxSize does not change in my database (checked with MySql Workbench).

How can I update new constraints in database?


Solution

  • GORM does not alter the existing column, when using dataSource.dbCreate = update. You should do it by yourself, using alter table statement.

    The best option, imo, is to use the migrations plugin; it is recently published. You can read the guide in here. Plugin documentation is available here.

    I suggest you to read the guide and refer to the documentation, provided above.