Grails automatic database transplant

DataSource.groovyFile dbCreateattribute is important because it can be used to specify whether to automatically according to GORM classes to create database tables. Its optional value:

  • create-drop - Remove and re-establish the database when Grails Runtime

  • create - If the database does not exist, create a database, there are not any changes

  • update - If the database does not exist, create the database, modify exists

Development environment (development) under dbCreateproperty default set to create-drop:

dataSource {
	dbCreate = "create-drop" // one of 'create', 'create-drop','update'
}

So that when Grails application starts will be removed and re-establish the original database, usually need to modify this value in a production environment.


Today there is a problem of production, production data was actually the cause of the problem adds a new field, on the grounds that some of the needs we have recently changed, added a new field, deployed to the QA system at the front desk when connected to the production database, and Logon Discovery there is a problem, immediately shutdow, and then, when the next day, when customers use, the function can not find some error, complaints to the afternoon, to find the reason for this is QA system has a new update to the fields of production, resulting in can not be used and later deleted this field, the system can finally be used, a scare. The final analysis, they do not care, then think about when the data source configuration dbCreate = update, and today a deep understanding for this field thoroughly. Very dangerous, so be careful when publishing to modify the configuration database, it will be very prone to problems, blood lesson today, but fortunately resolved.


Guess you like

Origin blog.51cto.com/7218743/2460015