我的数据库是 MSSQL。
我有一个迁移脚本,我在其中创建了这样的表:
module.exports = {
up: function(queryInterface) {
return queryInterface.createTable(
'tablename', {
'column1': {
type: SEQUELIZE.INTEGER,
references: {
model: 'Foobar',
key: 'id',
onDelete: 'cascade'
}
}
}
}
}
};
我想更改此列的引用,因此我编写了另一个迁移脚本:
module.exports = {
up: function(queryInterface) {
return queryInterface.changeColumn(
'tablename', {
'column1': {
type: SEQUELIZE.INTEGER,
references: {
model: 'BarFoo', //I changed the reference
key: 'id',
onDelete: 'cascade'
}
}
}
}
}
};
但是,在运行迁移时,我发现数据库中的引用没有改变。该列仍然引用旧的参考 -FooBar
而不是BarFoo
. 迁移脚本成功运行,但没有发生更改。知道为什么吗?
我使用 sequelize cli 运行迁移 -sequelize db:migrate