Fixed mysql 5.6 issue where a foreign key constraint will be violated