I have created a custom content-type in my custom module with custom fields.. It works fine.. But when I try to uninstall it, it doesnt call hook_unistall().. Can any one suggest what can be the problem ?
Here is my code :
function homepage_blocks_uninstall() {
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => 'homepage_blocks'));
//echo "hello";
//exit;
$nids = array();
foreach ($result as $row) {
$nids[] = $row->nid;
}
node_delete_multiple($nids);
foreach (array_keys(_homepage_blocks_installed_fields()) as $field) {
field_delete_field($field);
//db_drop_table($field);
}
$instances = field_info_instances('node', 'homepage_blocks');
foreach (_homepage_blocks_installed_instances() as $instance_name => $instance) {
field_delete_instance($instance);
}
node_type_delete('homepage_blocks');
field_purge_batch(1000);
//variable_del('comment_homepage_blocks');
//variable_del('node_submitted_homepage_blocks');
drupal_flush_all_caches();
//module_disable('homepage_blocks');
}
And I want to delete all tables, cache, variables node entries related to that module while uninstalling module so that I can re-install it.. What extra code I need ?
_homepage_blocks_installed_fields() and _homepage_blocks_installed_instances() are functions reside in homepage_blocks.functions.inc file and I have included this file to my homepage_blocks.module and homepage_blocks.install