I'm trying to add two foreign keys into my transaction table, one of then works just fine, but the second can't be implemented. Is there a way to set an array of foreign keys? I suppose the problem is the array, since it's the only thing different.
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('transactions', {
id:
{
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
value:
{
type: Sequelize.FLOAT,
allowNull: false,
},
clientId:
{
type: Sequelize.INTEGER,
allowNull: true,
references: { model: 'client', key: 'id'},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
productId:
{
type: Sequelize.ARRAY(Sequelize.INTEGER),
allowNull: false,
references: { model: 'products', key: 'id'},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
createdAt:
{
type: Sequelize.DATE,
allowNull: false,
},
updatedAt:
{
type: Sequelize.DATE,
allowNull: false,
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('transactions');
}
};
Code Fraction: