Deleting content types programmatically I'm trying to delete some content types which are no longer used but are still active.

I'm going to deploy the update using hook_update_N and have this so far (Code taken from node_type_delete_confirm_submit:

function hook_update_N(&amp;$sandbox) {
  node_type_delete('mynodetype');
  variable_del('node_preview_mynodetype');
  node_types_rebuild();
  menu_rebuild();
}


The problem I'm having is that the node type is deleted, but the nodes of that type are still there in the database. Running cron hasn't deleted those nodes (I'm not even sure if that's the default behavior when deleting content types through the admin UI)

My question is:


Are the nodes deleted automatically after a certain time through Cron or some other method? If not then doing it manually, would it be best to do it before deleting the content type or after?
$ournewtype = 'voucher';
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' =&gt; $ournewtype));
$nodeids = array();
foreach ($result as $row) {
  $nodeids[] = $row-&gt;nid;
}
node_delete_multiple($nodeids);
node_type_delete($ournewtype);