Intento crear una lista de tareas pendientes con Sequelize, pero siempre tengo este error: "No se puede agregar una restricción de clave externa usando Sequelize". Incluso buscando algunas pistas en StackOverflow, ¿alguien puede ayudar?
Migración de tareas pendientes
module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('Todos', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, description: { type: Sequelize.STRING, allowNull: false, }, createdAt: { allowNull: false, type: Sequelize.DATE, }, status_id: { type: Sequelize.INTEGER, allowNull: false, references: { model: 'Statuses', key: 'id', }, }, }); }, async down(queryInterface) { await queryInterface.dropTable('Todos'); }, };Migración de estado
module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('Statuses', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, name: { type: Sequelize.STRING, allowNull: false, }, }); }, async down(queryInterface) { await queryInterface.dropTable('Statuses'); }, }; Relationship in models // Status model Status.associate = (models) => { Status.belongsTo(models.Todo, { foreignKey: 'status_id', as: 'todo' }); }; // Todo model Todo.associate = (models) => { Todo.hasMany(models.Status, { foreignKey: 'status_id', as: 'statuses' }); };¡Si alguien tiene alguna idea, se lo agradezco mucho! Gracias