Stop the auto migration of the schema in the sails.js

一世执手 提交于 2019-11-28 03:20:25

问题


In sails.js, how can we stop the automigration of the schema into the database. Sometimes,it gives error due to the migration. Is there a way that we can make the migration run only when the application is deployed?


回答1:


You can also try something like this:

module.exports = {

  // migrate: 'alter', // adds and/or removes columns on changes to the schema 

  // migrate: 'drop', // drops all your tables and then re-creates them. All data is deleted.

  // migrate: 'safe', doesn't do anything on sails lift- for use in production.

  attributes: { /* ... */ }

};



回答2:


We can achieve that by specifying the migrate property in the model. Its default value is alter which attempt to auto-migrate the schema on every alteration.

module.exports = {
  schema: true,
  migrate: 'safe',
  adapter: 'mysql',

  attributes: {}
}



回答3:


For all models you can change in confing/models.js

migrate: 'safe',


来源:https://stackoverflow.com/questions/20490853/stop-the-auto-migration-of-the-schema-in-the-sails-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!