Pablo Mosby
Pablo Mosby

Reputation: 319

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?

Upvotes: 2

Views: 329

Answers (2)

Adeel Ansari
Adeel Ansari

Reputation: 39907

Another option is to use dbCreate: create-drop, if affordable..., I mean suitable, for your situation.

Upvotes: 0

Mario
Mario

Reputation: 4998

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.

Upvotes: 2

Related Questions