停止sails.js中模式的自动迁移

在sails.js中 ,我们如何停止模式到数据库的自动迁移。 有时,由于迁移而出现错误。 有没有一种方法可以让我们只在部署应用程序时才运行迁移?

你也可以尝试这样的事情:

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

我们可以通过在模型中指定migrate属性来实现这一点。 它的默认值是alter ,试图在每次更改时自动迁移模式。

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

对于所有模型,您可以在confing / models.js中更改

 migrate: 'safe',