function _update_7000_field_delete_instance

Deletes an instance and all its data of a field stored in SQL Storage.

BEWARE: This function deletes user data from the field storage tables.

Related topics

File

drupal/core/modules/field/field.install, line 282
Install, update, and uninstall functions for the Field module.

Code

function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) {

  // Delete field instance configuration data.
  db_delete('field_config_instance')
    ->condition('field_name', $field_name)
    ->condition('entity_type', $entity_type)
    ->condition('bundle', $bundle)
    ->execute();

  // Nuke data.
  db_delete('field_data_' . $field_name)
    ->condition('entity_type', $entity_type)
    ->condition('bundle', $bundle)
    ->execute();
  db_delete('field_revision_' . $field_name)
    ->condition('entity_type', $entity_type)
    ->condition('bundle', $bundle)
    ->execute();
}