迁移不适用于sails JS和postgresql db

时间:2016-01-25 20:38:18

标签: postgresql migration sails.js

我刚刚使用SailsJS加入了一个项目。我试图在用户模型上运行迁移(我想添加一个确认的列boolean)。我继续这样做:

1)我修改了models / User.js中的用户模型,添加了确认的属性。这是User.js的模型:

attributes: {

 id: {
    type: 'int',
    primaryKey: true,
    autoIncrement: true
  },
  confirmed: {
    type: 'boolean',
    required: true,
    defaultsTo: false
  },
  facebook_id: {
    type: 'int'
  },
  email: {
   type: 'string',
   unique:true,
   required: true
  },
  password:{
   type: 'string'
   // ,
   // password: true
  },
  password_confirmation:{
   type:'string'
  },
  token: {
    type:'string',
    size: 2000
  },
  first_name: {
    type: 'string',
    required: true
  },
  last_name: {
   type: 'string',
   required: true
  },
  full_name: {
    type: 'string'
  },
  poste: {
    type: 'string'
  },
  favorite_club: {
   type:'string'
  },
  picture: {
    type:'string',
    defaultsTo: 'https://wefoot.s3.amazonaws.com/default.svg'
  },
  birthday: {
    type: 'date'
  },
  mangoId: {
    type: 'integer'
  },
  telephone: {
    type: 'string'
  },
  password_reset_token:{
    type:'string'
  },
  last_seen:{   //Last opening of notif page
    type:'datetime'
  },
  pending_notif:{
    type:'int',
    defaultsTo: 0
  },
  nb_connection:{
    type:'int',
    defaultsTo: 0
  },
  last_lat:{
    type: 'float'
  },
  last_long:{
    type: 'float'
  },

2)在config / env / development.js中,我更改了migrate:safe to migrate alter:

module.exports = {
  models: {
    connection: 'postgresLocal',
    migrate: 'alter'
  }
};

3)我跑了帆升降机并更改了development.js以迁移安全

但是当我检查Pgadmin时,新确认的列没有显示,我在日志中收到此错误

Unhandled rejection Error (E_VALIDATION) :: 1 attribute is invalid
    at WLValidationError.WLError (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/error/WLError.js:26:15)
    at new WLValidationError (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/error/WLValidationError.js:20:28)
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:46:43
    at allValidationsChecked (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/core/validations.js:210:5)
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
    at done (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:239:19)
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/core/validations.js:191:23
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
    at done (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:239:19)
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/lib/waterline/core/validations.js:164:64
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:162:20
    at /Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:230:13
    at _arrayEach (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:81:9)
    at _each (/Users/davidgeismar/wefootpostgres/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:72:13) 

我在这里做错了什么?

0 个答案:

没有答案