当我在这个类上运行迁移时,我希望能够分配一个 id 和一个 UUID。将 id 设置为主键,将 UUID 设置为默认值。但是,当我运行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;
};