field.install 4.69 KB
Newer Older
Dries's avatar
 
Dries committed
1 2
<?php
// $Id$
3

4 5 6 7 8
/**
 * @file
 * Install, update and uninstall functions for the field module.
 */

Dries's avatar
 
Dries committed
9
/**
10
 * Implements hook_schema().
Dries's avatar
 
Dries committed
11 12 13 14 15
 */
function field_schema() {
  // Static (meta) tables.
  $schema['field_config'] = array(
    'fields' => array(
16 17 18 19 20
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'The primary identifier for a field',
      ),
Dries's avatar
 
Dries committed
21 22 23 24
      'field_name' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
25
        'description' => 'The name of this field. Non-deleted field names are unique, but multiple deleted fields can have the same name.',
Dries's avatar
 
Dries committed
26 27 28 29 30
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
31
        'description' => 'The type of this field.',
Dries's avatar
 
Dries committed
32
      ),
33 34 35 36 37 38 39 40
     'module' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The module that implements the field type.',
      ),
      'active' => array(
Dries's avatar
 
Dries committed
41 42 43 44
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
45
        'description' => 'Boolean indicating whether the module that implements the field type is enabled.',
Dries's avatar
 
Dries committed
46
      ),
47 48 49
      'storage_type' => array(
        'type' => 'varchar',
        'length' => 128,
Dries's avatar
 
Dries committed
50
        'not null' => TRUE,
51
        'description' => 'The storage backend for the field.',
Dries's avatar
 
Dries committed
52
      ),
53
      'storage_module' => array(
Dries's avatar
 
Dries committed
54 55 56 57
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
58
        'description' => 'The module that implements the storage backend.',
Dries's avatar
 
Dries committed
59
      ),
60
      'storage_active' => array(
Dries's avatar
 
Dries committed
61 62 63
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
64
        'default' => 0,
65
        'description' => 'Boolean indicating whether the module that implements the storage backend is enabled.',
Dries's avatar
 
Dries committed
66
      ),
67
      'locked' => array(
68 69 70 71
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
72
        'description' => '@TODO',
73
      ),
74
      'data' => array(
75 76
        'type' => 'blob',
        'size' => 'big',
77 78 79 80 81 82 83 84 85 86 87
        'not null' => TRUE,
        'serialize' => TRUE,
        'description' => 'Serialized data containing the field properties that do not warrant a dedicated column.',
      ),
      'cardinality' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'translatable' => array(
Dries's avatar
 
Dries committed
88 89 90
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
91
        'default' => 0,
Dries's avatar
 
Dries committed
92 93 94 95 96 97 98 99
      ),
      'deleted' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
100
    'primary key' => array('id'),
Dries's avatar
 
Dries committed
101
    'indexes' => array(
102
      'field_name' => array('field_name'),
103 104 105 106 107
      // Used by field_read_fields().
      'active' => array('active'),
      'storage_active' => array('storage_active'),
      'deleted' => array('deleted'),
      // Used by field_modules_disabled().
Dries's avatar
 
Dries committed
108
      'module' => array('module'),
109 110
      'storage_module' => array('storage_module'),
      // Used by field_associate_fields().
Dries's avatar
 
Dries committed
111
      'type' => array('type'),
112
      'storage_type' => array('storage_type'),
Dries's avatar
 
Dries committed
113 114 115 116
    ),
  );
  $schema['field_config_instance'] = array(
    'fields' => array(
117 118 119 120 121 122 123 124 125 126
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'The primary identifier for a field instance',
      ),
      'field_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'The identifier of the field attached by this instance',
      ),
127 128 129
      'field_name' => array(
        'type' => 'varchar',
        'length' => 32,
Dries's avatar
 
Dries committed
130
        'not null' => TRUE,
131 132
        'default' => ''
      ),
133
      'entity_type'       => array(
134 135 136 137 138
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => ''
      ),
139 140 141 142 143
      'bundle' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => ''
Dries's avatar
 
Dries committed
144 145
      ),
      'data' => array(
146 147
        'type' => 'blob',
        'size' => 'big',
Dries's avatar
 
Dries committed
148 149 150 151 152 153 154 155 156 157
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'deleted' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
158
    'primary key' => array('id'),
Dries's avatar
 
Dries committed
159
    'indexes' => array(
160
      // Used by field_delete_instance().
161
      'field_name_bundle' => array('field_name', 'entity_type', 'bundle'),
162 163
      // Used by field_read_instances().
      'deleted' => array('deleted'),
Dries's avatar
 
Dries committed
164 165 166 167 168 169
    ),
  );
  $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache');

  return $schema;
}