You are here

function sheetnode_update_7002 in Sheetnode 7

Same name and namespace in other branches
  1. 7.2 sheetnode.install \sheetnode_update_7002()

Implements hook_update_N(). Add 'name' field to sheetfields.

File

./sheetnode.install, line 191
Install, update and uninstall functions for the sheetnode module.

Code

function sheetnode_update_7002(&$sandbox) {

  // @see http://drupal.stackexchange.com/questions/30301/update-field-schema
  $fields = field_info_fields();
  foreach ($fields as $field_name => $field) {
    if ($field['type'] == 'sheetfield' && $field['storage']['type'] == 'field_sql_storage') {
      $schema = sheetnode_field_schema_7002($field);
      foreach ($field['storage']['details']['sql'] as $type => $table_info) {
        foreach ($table_info as $table_name => $columns) {
          $column_name = _field_sql_storage_columnname($field_name, 'name');
          db_add_field($table_name, $column_name, $schema['columns']['name']);
          db_add_index($table_name, $column_name, array(
            $column_name,
          ));
        }
      }
    }
  }
  field_cache_clear();
}