fixed setPermissions bug, still failing foreign key constraint