File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 1414
1515module . exports . bootstrap = function ( next ) {
1616 // Check if we need to validate our schema
17- if ( sails . config . models . migrate === 'safe' ) { // aka PRODUCTION
17+ if ( sails . config . models . validateOnBootstrap && sails . config . models . migrate === 'safe' ) { // aka PRODUCTION
1818 let waitingToFinish = 0 ;
1919
2020 _ . forEach ( sails . models , ( model , modelName ) => {
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ module.exports = {
2121 * environment (see config/datastores.js and config/models.js ) *
2222 ***************************************************************************/
2323
24- datastores : {
25- host : process . env . DB_HOST || 'localhost' ,
26- user : process . env . DB_USER || 'root' ,
27- password : process . env . DB_PASS || 'mypass' ,
28- database : process . env . DB_NAME || 'myapp' ,
29- port : process . env . DB_PORT || 3306 ,
30- ssl : ( process . env . DB_SSL === 'true' )
31- } ,
24+ // datastores: {
25+ // host: process.env.DB_HOST || 'localhost',
26+ // user: process.env.DB_USER || 'root',
27+ // password: process.env.DB_PASS || 'mypass',
28+ // database: process.env.DB_NAME || 'myapp',
29+ // port: process.env.DB_PORT || 3306,
30+ // ssl: (process.env.DB_SSL === 'true')
31+ // },
3232
3333 models : {
3434 migrate : 'safe' // This is set as safe, so remote development machines are behaving like remote production machines. Use local.js to override.
Original file line number Diff line number Diff line change @@ -104,6 +104,20 @@ module.exports.models = {
104104 * *
105105 ***************************************************************************/
106106
107- cascadeOnDestroy : true
107+ cascadeOnDestroy : true ,
108+
109+
110+ /********************************************************************************
111+ * *
112+ * This is a custom property, that is used inside of config/bootstrap.js. *
113+ * If set to true AND sails.config.models.migrate === 'safe', then the *
114+ * database schema validation and enforcement goes to work. If the database *
115+ * is not configured according to the model specifications, the problem areas *
116+ * will be console.error()'d, and Sails will fail to lift. This is intended for *
117+ * remote environments, to help prevent accidental deployment of an *
118+ * incompatible version for the given datastore. *
119+ * *
120+ ********************************************************************************/
121+ validateOnBootstrap : true
108122
109123} ;
You can’t perform that action at this time.
0 commit comments