Sequelize-CLI:运行迁移

时间:2017-02-22 20:49:21

标签: sequelize.js sequelize-cli

当我在这个类上运行迁移时,我希望能够分配一个id和一个UUID。将id设置为主键,将UUID设置为defaultvalue。但是,当我运行sequelize db:migrate命令时,我收到了非常模糊的错误:

  

val.replace不是一个函数:

这是我的代码:

'use strict';

module.exports = (sequelize, Sequelize) => {
 const projects = sequelize.define('projects',
  {
   id: {
    type: Sequelize.UUID,
    allowNull: false,
    primaryKey: true,
    unique: true
  },
  uid: {
    type: Sequelize.UUID,
    allowNull: false,
    defaultValue: Sequelize.UUIDV4,

  },
  client: {
    type: Sequelize.STRING(255),
    allowNull: false
  },
  name: {
    type: Sequelize.STRING(255),
    allowNull: false
  },

},
{
  tableName: 'projects',
  freezeTableName: true,
  underscored: false,
  // don't forget to enable timestamps!
  timestamps: true,
  // I don't want createdAt
  createdAt: 'dateCreated',
  // I want updatedAt to actually be called updateTimestamp
  updatedAt: 'dateModified',
  // And deletedAt to be called destroyTime (remember to enable paranoid for this to work)
  deletedAt: 'dateDestroyed',
  // Paranoid will not delete tables from cascade only add delete to active

});

  return projects;
};

0 个答案:

没有答案
相关问题