field_info_instance returns empty in hook_uninstall In a custom module, I'm creating a new field and instance for a custom entity type like this:

function mymodule_install() {
  if (!field_info_field('mymodule_field')) {
    $field = array( .... );
    field_create_field($field);
  }
  if (!field_info_instance('mymodule_entity','mymodule_field', 'bundle1')) {
    $instance = array( .... );
    field_create_instance($instance);
  }
}

function mymodule_uninstall() {
  if ($instance = field_info_instance('mymodule_entity','mymodule_field', 'bundle1')) {
    field_delete_instance($instance);
  }
  if (field_info_field('mymodule_field')) {
    field_delete_field('mymodule_field');
  }
  field_purge_batch(100);
}


...and the field and instance gets created properly. However upon uninstalling the module, only the field tables are being deleted while the field instance is still there in the field_config_instance table still having deleted = 0.

Debugging the uninstall process reveals that field_info_instance (and field_read_instances) is returning NULL...

Anyone knows what I'm doing wrong? I'm on a fresh Drupal 7.23 install...
You don't need field_delete_instance separately, because field_delete_field has it inside.

According to deleted column in field_config (you can skip this value in field_config_instance if you're deleting whole field) debug field_delete_field function.