我正在使用sequelize 和node.js。我有一列想要将其类型更改为唯一,当我想要运行迁移时,我遇到了这个错误,我该如何解决它?
ERROR: SequelizeUniqueConstraintError: Validation error
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.changeColumn('PersonalInfo', 'ssn', {type: Sequelize.STRING, unique: true
}),
queryInterface.changeColumn('PersonalInfoDraft', 'ssn', {type: Sequelize.STRING, unique:true
})
])
}
Run Code Online (Sandbox Code Playgroud) 我正在使用sequelize 和node.js。我想将 PrimaryPractice 模型的列值相互连接。我怎么解决这个问题?这是我的代码:
ProviderPayer.findAll({
where: {
orgPayerId: {
[Op.in]: orgPayerIds
}
},
attributes: ["effective_date"],
include: [{
model: PayerTracks,
attributes: ["title"],
as: "payers",
},
{
model: User,
where: {
id: {[Op.in]: userIds},
deletedAt: null,
status: {[Op.ne]: STATUS.INACTIVE}
},
attributes: ["id"],
include: [
{
model: PrimaryPractice,
as: "primaryPractice",
attributes: [
"addressStreetPrimPract",
"addressStreet2PrimPract",
"addressCityPrimPract",
"addressStatePrimPract",
"addressZipPrimPract"]
}
]
}
]
})
Run Code Online (Sandbox Code Playgroud)