0
I have a Migration that adds a reference to a column (foreign key), but at the time I run db:migrate:undo
He doesn’t break up the relationship at the bank. After some tests the migrations continue not matching, only now I have the same relationship established N times, as shown in the following picture:
What is the simplest and most direct way to undo this?
Follow the Migration code:
'use strict';
const { NONE } = require("sequelize");
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.changeColumn('area_informations', 'information_type_id', {
type: Sequelize.INTEGER,
allowNull: false,
references: {
key: 'id',
model: 'information_types'
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.changeColumn('area_informations', 'information_type_id', {
type: Sequelize.INTEGER,
allowNull: false,
references: NONE
});
}
};
OBS: In the first attempt the method down
had no option to references
because theoretically it would overwrite right?
Has a method
removeConstraint
, looks like it fits but I’m not sure– Rafael Tavares