Bác nào giúp em fix lỗi này với Cannot delete or update a parent row: a foreign key constraint fails

My code is:

"use strict";
module.exports = function(sequelize, DataTypes) {
var Threshold = sequelize.define("threshold", {
threshold_id:{
    type: DataTypes.INTEGER,            
    primaryKey: true,
    autoIncrement: true        
            },
datatype_id:{
    type: DataTypes.CHAR(3),
    allowNull: false,
    references:{
        model: 'data_type',
        key: 'datatype_id'
    }
},
region_id:{
    type: DataTypes.INTEGER,
    allowNull: true,
    references:{
        model: 'region',
        key: 'region_id'
    }
},
age_id:{
    type: DataTypes.INTEGER,
    allowNull: true,
    references:{
        model: 'age',
        key: 'age_id'
    }
},
species_id:{
    type: DataTypes.INTEGER,
    allowNull: true,
    references:{
        model: 'species',
        key: 'species_id'
    }
},
threshold_name:{
    type:  DataTypes.STRING(255),
    allowNull: false
},
threshold_start:{
    type: DataTypes.FLOAT,
    allowNull: false,
    validate:{
        isFloat: true
    } 
},
threshold_end:{
    type: DataTypes.FLOAT,
    allowNull: false,
    validate:{
        isFloat: true
    } 
},
threshold_level: {
    type: DataTypes.INTEGER,
    allowNull: false,
    validate:{
        isInt: true
    } 
},
threshold_message:{
    type: DataTypes.TEXT,
    allowNull: false
},
threshold_createdDate:{
    type: DataTypes.DATE,
    defaultValue: sequelize.NOW
},

threshold_timeWarning:{
    type: DataTypes.INTEGER,
    allowNull: true,
    validate:{
        isInt: true
    } 
},
threshold_type:{
    type: DataTypes.BOOLEAN,
    allowNull:true
}
}, 
  {
 tableName: "threshold",
 timestamps: false,
 freezeTableName: false,
 classMethods: {
    associate: function(models) {
       Threshold.belongsTo(models.data_type, {foreignKey:'datatype_id',  targetKey: 'datatype_id', as: 'Data_Type'});
       Threshold.belongsTo(models.age, {foreignKey:'age_id',  targetKey: 'age_id', as: 'Age'});
       Threshold.belongsTo(models.region, {foreignKey:'region_id',  targetKey: 'region_id', as: 'Region'});
       Threshold.belongsTo(models.species, {foreignKey:'species_id',  targetKey: 'species_id', as: 'Species'});
       Threshold.hasMany(models.advice, {foreignKey: 'threshold_id', targetKey: 'threshold_id' , onDelete: 'CASCADE', hooks: true});
       Threshold.hasMany(models.notification,{ foreignKey: 'threshold_id', targetKey: 'threshold_id'});
   }
 }
 });
return Threshold;
};

Advice

"use strict";
var Threshold = ("../threshold");
module.exports = function(sequelize, DataTypes) {
var Advice = sequelize.define("advice", {
advice_id:{
    type: DataTypes.INTEGER,            
    primaryKey: true,
    autoIncrement: true        
},
user_id:{
    type: DataTypes.INTEGER,
    allowNull: false,
    references:{
        model: 'user',
        key: 'user_id'
    },
    validate:{
        isInt: true
    }
},
threshold_id:{
    type: DataTypes.INTEGER,
    allowNull: false, 
    references:{
        model: 'threshold',
        key: 'threshold_id'
    },
    validate:{
        isInt: true
    }
},
advice_title: {
    type: DataTypes.STRING(200),
    allowNull: true
},
advice_message:{
    type:  DataTypes.TEXT,
    allowNull: false
},
advice_createdDate:{
    type: DataTypes.DATE,
    defaultValue: sequelize.NOW
}
 }, 
{
 tableName: "advice",
 timestamps: false,
 freezeTableName: false,
 classMethods: {
    associate: function(models) {
       Advice.belongsTo(models.user, {foreignKey:'user_id',  targetKey: 'user_id', as: 'User'});
       Advice.belongsTo(models.threshold, {foreignKey:'threshold_id',  targetKey: 'threshold_id', as: 'Threshold'});
   }
 }
});
return Advice;
};
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?