Mysql 在帆式升降机上停止立柱/工作台更换的方法

Mysql 在帆式升降机上停止立柱/工作台更换的方法,mysql,node.js,sails.js,Mysql,Node.js,Sails.js,我使用的是sails版本0.11.2。下面是代码 config/models.js 在我的sails应用程序中 /** * Default model configuration * (sails.config.models) * * Unless you override them, the following properties will be included * in each of your models. * * For more info on Sails mode

我使用的是sails版本0.11.2。下面是代码

config/models.js

在我的sails应用程序中

/**
 * Default model configuration
 * (sails.config.models)
 *
 * Unless you override them, the following properties will be included
 * in each of your models.
 *
 * For more info on Sails models, see:
 * http://sailsjs.org/#!/documentation/concepts/ORM
 */

module.exports.models = {
  connection: 'mysqldb',
  migrate: 'safe',
  schema : true
};
根据sails,migrate:“safe”应该停止自动迁移,并且不会更改数据库中的任何列或表

但是,每当一条注释指向模型的任何属性并尝试提升sails应用程序时,与该属性关联的列都会从mysql数据库中删除


注意:如果您需要任何附加信息或示例代码,请进行注释,以备查询。

在每个型号中分别添加代码
migrate:“safe”
,即可解决此问题。现在,文件Consumer.js中的消费者模型如下所示:

/**
* Consumer.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs        :: http://sailsjs.org/#!documentation/models
*/

module.exports = {
  migrate      : 'safe',
  autoPK       : true,
  autoCreatedAt: true,
  autoUpdatedAt: true,
  attributes   : {
    name: {
      type     : 'string',
      required : true,
      minLength: 3
    },

    email: {
      type    : 'string',
      required: true,
      unique  : true
    },
  tableName    : 'consumers'
};

虽然这个解决方案可行,但我相信还有一个更好的解决方案,在所有模型中都不涉及这种代码声誉。因此,不要将此问题标记为已通过此答案解决。

您能向我们展示config/models.js的所有代码吗?您使用的是哪个版本的sails?@piscator我已经用config/models.js的完整文件以及sails版本更新了这个问题。请尝试将模式选项移动到您使用的每个模型,模式:true,连接:'mysqldb',表名:'yourTable',属性:{}