Javascript Sequelize索引已存在运行应用程序时出现错误
我创建了这个迁移文件:Javascript Sequelize索引已存在运行应用程序时出现错误,javascript,node.js,indexing,sequelize.js,Javascript,Node.js,Indexing,Sequelize.js,我创建了这个迁移文件: 'use strict'; module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('note_tags', { id: { type: Sequelize.INTEGER, allowNull: false, primaryKey: true, autoInc
'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('note_tags', {
id: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
note_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'notes',
key: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
tag_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'tags',
key: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
});
await queryInterface.addIndex('note_tags', ['note_id']);
return queryInterface.addIndex('note_tags', ['tag_id']);
},
down(queryInterface) {
return queryInterface.dropTable('note_tags');
},
};
现在,当我运行应用程序时,出现以下错误:
UnhandledPromiseRejectionWarning: SequelizeDatabaseError: relation "note_tags_note_id" already exists
索引确实存在于我的本地数据库中。我不知道该怎么办,因为我为供应商用户
提供了类似的服务,但使用了供应商用户
索引,但从未收到此问题
如何解决此问题?我刚从数据库中删除了索引并重新启动了应用程序。我刚从数据库中删除了索引并重新启动了应用程序