'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.addColumn('Posts', 'userAccountId', {
type: Sequelize.INTEGER,
}),
queryInterface.addColumn('Posts', 'postTopicId', {
type: Sequelize.INTEGER,
}),
queryInterface.addConstraint('Posts', ['userAccountId'], {
type: 'foreign key',
name: 'userAccountId',
references: {
table: 'UserAccounts',
field: 'id',
},
onDelete: 'no action',
onUpdate: 'no action',
}),
queryInterface.addConstraint('Posts', ['postTopicId'], {
type: 'foreign key',
name: 'postTopicId',
references: {
table: 'PostTopics',
field: 'id',
},
onDelete: 'no action',
onUpdate: 'no action',
}),
]);
},
down: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.removeColumn('Posts', 'userAccountId'),
queryInterface.removeColumn('Posts', 'postTopicId'),
queryInterface.removeConstraint('Posts', 'userAccountId'),
queryInterface.removeConstraint('Posts', 'postTopicId'),
]);
},
};
When I run the command npx sequelize db:migrate, I receive this error "ERROR: column "postTopicId" referenced in foreign key constraint does not exist"
I dont what is wrong, all the other migrations running ok. I'm running my database in a docker container.