{"action":"opened","issue":{"url":"https://api.github.com/repos/franzose/ClosureTable/issues/138","labels_url":"https://api.github.com/repos/franzose/ClosureTable/issues/138/labels{/name}","comments_url":"https://api.github.com/repos/franzose/ClosureTable/issues/138/comments","events_url":"https://api.github.com/repos/franzose/ClosureTable/issues/138/events","html_url":"https://github.com/franzose/ClosureTable/issues/138","id":54944953,"number":138,"title":"Integrity constraint violation when deleting child objects","user":{"login":"greggilbert","id":169482,"avatar_url":"https://avatars.githubusercontent.com/u/169482?v=3","gravatar_id":"","url":"https://api.github.com/users/greggilbert","html_url":"https://github.com/greggilbert","followers_url":"https://api.github.com/users/greggilbert/followers","following_url":"https://api.github.com/users/greggilbert/following{/other_user}","gists_url":"https://api.github.com/users/greggilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/greggilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greggilbert/subscriptions","organizations_url":"https://api.github.com/users/greggilbert/orgs","repos_url":"https://api.github.com/users/greggilbert/repos","events_url":"https://api.github.com/users/greggilbert/events{/privacy}","received_events_url":"https://api.github.com/users/greggilbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-20T21:48:24Z","updated_at":"2015-01-20T21:48:24Z","closed_at":null,"body":"Hey. This package is excellent, but I'm having an issue when deleting child objects.\r\n\r\nI've tried it a number of ways, including:\r\n\r\n```php\r\n$unitToRemove = \\Unit::find($id);\r\n$parentUnit->removeChild($unitToRemove->position, true);\r\n```\r\n```php\r\n$unitToRemove = \\Unit::find($id);\r\n$unitToRemove->deleteSubtree(true, true);\r\n$parentUnit->removeChild($unitToRemove->position, true);\r\n```\r\n```php\r\n$unitToRemove->delete();\r\n```\r\n\r\nand so on, but I get a violation:\r\n\r\n```\r\n\"SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`database`.`unit_closure`, CONSTRAINT `unit_closure_ancestor_foreign` FOREIGN KEY (`ancestor`) REFERENCES `units` (`id`)) (SQL: delete from `units` where `parent_id` = 33 and `position` = 0)\"\r\n```\r\n\r\nPresumably I'm doing something wrong here, but I'm not sure what. Any ideas?"}}