OL

Вопрос в чем.
Нужно запилить associations такого вида:
module.exports = (sequelize, DataTypes) => {
const History = sequelize.define('History', {
WatchId:{
type: DataTypes.INTEGER,
references: {
model: 'Watch',
key: 'id'
}
},
historableId: DataTypes.INTEGER,
historableType: DataTypes.STRING
}, {
getHistorable(options) {
if (!this.historableType) return Promise.resolve(null);
const mixinMethodName = `get${uppercaseFirst(this.historableType)}`;
return this[mixinMethodName](options);
}
});
History.associate = function(models) {
// associations can be defined here
History.belongsTo(models.Watch);
History.belongsTo(models.Maintenance, { foreignKey: 'historableId', constraints: false });
History.belongsTo(models.TransferWatch, { foreignKey: 'historableId', constraints: false });
};
return History;
};