You are here

function domain_entity_update_7005 in Domain Access Entity 7

Implements hook_update_N().

Add support for domain source. Add a column domain_source to the field domain.

File

./domain_entity.install, line 64
Domain Access Entity install function

Code

function domain_entity_update_7005() {
  $fields = field_info_fields();
  foreach ($fields as $field_name => $field) {
    if ($field['type'] == 'domain_entity' && $field['storage']['type'] == 'field_sql_storage') {
      $schema = array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => FALSE,
        'default' => 0,
        'description' => 'A boolean indicating whether this domain_id is the canonical domain',
      );
      foreach ($field['storage']['details']['sql'] as $type => $table_info) {
        foreach ($table_info as $table_name => $columns) {
          $column_name = _field_sql_storage_columnname($field_name, 'domain_source');
          db_add_field($table_name, $column_name, $schema);
          db_add_index($table_name, $column_name, array(
            $column_name,
          ));
        }
      }
    }
  }
  field_cache_clear();
}