1
我想通过使用Sequelize和Postgresql显式创建的联结表添加多对多关系。Sequelize重复键约束违规
的关系两侧的表是这样的关联:
Shop.belongsToMany(models.user, {through: 'visits' })
User.belongsToMany(models.shop, {through: 'visits' })
而且探访结表的主键的定义是这样的:
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true // Automatically gets converted to SERIAL for postgres
}
当我尝试插入访问我得到以下错误:
ERROR: duplicate key value violates unique constraint "visits_shopId_userId_key"
DETAIL: Key ("shopId", "userId")=(1, 12) already exists.
做了一个pg_dump后,我有tr通过向模型添加约束:false来删除组合键约束,但我仍然收到错误。
(I已经下降的表和重新同步在调试过程中几次)