summaryrefslogtreecommitdiff
path: root/modules/field/modules/field_sql_storage/field_sql_storage.install
blob: b31a945397b7e0907345734c2da222861a9b5d5d (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
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// $Id$

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

/**
 * Implementation of hook_install().
 */
function field_sql_storage_install() {
  drupal_install_schema('field_sql_storage');
}

/**
 * Implementation of hook_uninstall().
 */
function field_sql_storage_uninstall() {
  drupal_uninstall_schema('field_sql_storage');
}

/**
 * Implementation of 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) {
      $schema += _field_sql_storage_schema($field);
    }
  }
  return $schema;
}