I would like to add a constraint inside my migration file, for example when I try and delete a row and there's another row inside another table that's referencing the row i'm deleting it needs to throw an error. There will also be multiple tables that will associate with the table.
return queryInterface.createTable('status', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING,
unique: true
},
slug: {
type: Sequelize.STRING,
unique: true
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
},
});
table status: ... id
table locales: ... id_status
table users ... id_status