I am getting the following error msg when I am trying to delete a group:
Cannot delete or update a parent row: a foreign key constraint fails
(asset_base.catgroup, CONSTRAINTcatgroup_ibfk_2FOREIGN KEY
(group_id) REFERENCESgroups(gid) ON UPDATE CASCADE)
I am not quite sure what to do. I am thinking that this would enable the deletion of group, but I am not quite sure, so I figured that someone here might know. I am trying to delete info from the groups table and it is linked to catgroup table. So if I add ON DELETE CASCADE restriction to catgroup i should be ok, right?
If I am on the right track I still would like to know how can I add a ON DELETE CASCADE option to a allready made table, hopefully without having to delete any cells or having to recreate the whole table?
Thank you!
The problem will be fixed when you (indeed) add the
ON DELETE CASCADEto your foreign key.You do not have to recreate the table. Just drop the constraint
catgroup_ibfk_2and re-create it. This time with theON DELETE CASCADEoption.Good luck!