NULL out parent_id column prior to running delete to avoid foreign key conflicts
Tweak subject/agent permission migration to avoid errors in Derby with distinct