summaryrefslogtreecommitdiff
path: root/modules/field/modules/field_sql_storage/field_sql_storage.install
blob: 7ab6a8cf9aec5a841f91e7d2df7e943056c43d0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// $Id$

/**
 * @file
 * Install, update and uninstall functions for the field_sql_storage module.
 */

/**
 * Implement hook_schema().
 */
function field_sql_storage_schema() {
  $schema = array();

  // Static (meta-data) tables.
  $schema['field_config_entity_type'] = array(
    'fields' => array(
      'etid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The unique id for this entity type',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'An entity type',
      ),
    ),
    'primary key' => array('etid'),
    'unique keys' => array('type' => array('type')),
  );

  // Dynamic (data) tables.
  if (db_table_exists('field_config')) {
    $fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
    drupal_load('module', 'field_sql_storage');
    foreach ($fields as $field) {
      if ($field['storage']['type'] == 'field_sql_storage') {
        $schema += _field_sql_storage_schema($field);
      }
    }
  }
  return $schema;
}