最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Stop the auto migration of the schema in the sails.js - Stack Overflow

programmeradmin5浏览0评论

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?

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?

Share Improve this question edited Nov 5, 2015 at 21:48 Joe Hill 3333 silver badges12 bronze badges asked Dec 10, 2013 at 9:40 Luja ShresthaLuja Shrestha 2,8572 gold badges24 silver badges29 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

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: { /* ... */ }

};

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: {}
}

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

migrate: 'safe',
发布评论

评论列表(0)

  1. 暂无评论