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 14
14
15
15
module . exports . bootstrap = function ( next ) {
16
16
// 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
18
18
let waitingToFinish = 0 ;
19
19
20
20
_ . forEach ( sails . models , ( model , modelName ) => {
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ module.exports = {
21
21
* environment (see config/datastores.js and config/models.js ) *
22
22
***************************************************************************/
23
23
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
+ // },
32
32
33
33
models : {
34
34
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 = {
104
104
* *
105
105
***************************************************************************/
106
106
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
108
122
109
123
} ;
You can’t perform that action at this time.
0 commit comments