Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when dbCreate is not specified?

Tags:

grails

According to the official Grails documentation, it is recommended NOT to specify the dbCreate property in production. So, what happens in that case? Will Grails do anything, such as validation, when the production war file is initially loaded on the container (Tomcat, for instance)? If validation is done, what is the difference from dbCreate="validate"? Or simply nothing, leaving it up to the developer to make sure the mapping between the domain classes and the database schema is correct? Thank you in advance.

like image 841
JBT Avatar asked Sep 15 '13 21:09

JBT


2 Answers

Keeping dbCreate empty is a very bad idea: configuration is merged with that of the individual plugins and nothing good can happen if the configuration system decides you haven't set your dbCreate property and decides to use the value supplied by a random plugin. What if that plugin orders a drop-create on your multiple gigabyte (or even production) database?

like image 20
Gregor Petrin Avatar answered Oct 19 '22 21:10

Gregor Petrin


When dbCreate is not specified, is set to an empty string (dbCreate = ""), or is set to anything other than create, create-drop, update, or validate, then simply nothing happens. The database does not get created, validated, or updated.

From the doc, you can use create, create-drop, update, or validate, and "any other value - does nothing". It also says "You can also remove the dbCreate setting completely, which is recommended once your schema is relatively stable and definitely when your application and database are deployed in production. Database changes are then managed through proper migrations, either with SQL scripts or a migration tool like Liquibase (the Database Migration plugin uses Liquibase and is tightly integrated with Grails and GORM)."

like image 67
grantmcconnaughey Avatar answered Oct 19 '22 23:10

grantmcconnaughey