You are here

function _update_7000_field_delete_instance in Drupal 7

Utility function: delete an instance and all its data of a field stored in SQL Storage.

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

This function is valid for a database schema version 7000.

Related topics

1 call to _update_7000_field_delete_instance()
taxonomy_update_7005 in modules/taxonomy/taxonomy.install
Migrate {taxonomy_term_node} table to field storage.

File

modules/field/field.install, line 290
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();
}