Skip to content
field.install 4.7 KiB
Newer Older
Dries Buytaert's avatar
Dries Buytaert committed
<?php
// $Id$
/**
 * @file
 * Install, update and uninstall functions for the field module.
 */

Dries Buytaert's avatar
Dries Buytaert committed
/**
Dries Buytaert's avatar
Dries Buytaert committed
 */
function field_schema() {
  // Static (meta) tables.
  $schema['field_config'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'The primary identifier for a field',
      ),
Dries Buytaert's avatar
Dries Buytaert committed
      'field_name' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'The name of this field. Non-deleted field names are unique, but multiple deleted fields can have the same name.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'description' => 'The type of this field.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
     'module' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The module that implements the field type.',
      ),
      'active' => array(
Dries Buytaert's avatar
Dries Buytaert committed
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Boolean indicating whether the module that implements the field type is enabled.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
      'storage_type' => array(
        'type' => 'varchar',
        'length' => 128,
Dries Buytaert's avatar
Dries Buytaert committed
        'not null' => TRUE,
        'description' => 'The storage backend for the field.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
Dries Buytaert's avatar
Dries Buytaert committed
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The module that implements the storage backend.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
Dries Buytaert's avatar
Dries Buytaert committed
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'description' => 'Boolean indicating whether the module that implements the storage backend is enabled.',
Dries Buytaert's avatar
Dries Buytaert committed
      ),
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      'data' => array(
        'type' => 'text',
        'size' => 'medium',
        '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 Buytaert's avatar
Dries Buytaert committed
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
Dries Buytaert's avatar
Dries Buytaert committed
      ),
      'deleted' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
Dries Buytaert's avatar
Dries Buytaert committed
    'indexes' => array(
      // Used by field_read_fields().
      'active' => array('active'),
      'storage_active' => array('storage_active'),
      'deleted' => array('deleted'),
      // Used by field_modules_disabled().
Dries Buytaert's avatar
Dries Buytaert committed
      'module' => array('module'),
      'storage_module' => array('storage_module'),
      // Used by field_associate_fields().
Dries Buytaert's avatar
Dries Buytaert committed
      'type' => array('type'),
Dries Buytaert's avatar
Dries Buytaert committed
    ),
  );
  $schema['field_config_instance'] = array(
    'fields' => array(
      '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',
      ),
      'field_name' => array(
        'type' => 'varchar',
        'length' => 32,
Dries Buytaert's avatar
Dries Buytaert committed
        'not null' => TRUE,
      'object_type'       => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => ''
      ),
      'bundle' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => ''
Dries Buytaert's avatar
Dries Buytaert committed
      ),
      'data' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'deleted' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
Dries Buytaert's avatar
Dries Buytaert committed
    'indexes' => array(
      'field_name_bundle' => array('field_name', 'object_type', 'bundle'),
      // Used by field_read_instances().
      'deleted' => array('deleted'),
Dries Buytaert's avatar
Dries Buytaert committed
    ),
  );
  $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache');

  return $schema;
}