You are here

function field_collection_schema in Field collection 7

Implements hook_schema().

File

./field_collection.install, line 11
Install, update and uninstall functions for the field_collection module.

Code

function field_collection_schema() {
  $schema['field_collection_item'] = array(
    'description' => 'Stores information about field collection items.',
    'fields' => array(
      'item_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique field collection item ID.',
      ),
      'revision_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'Default revision ID.',
      ),
      'field_name' => array(
        'description' => 'The name of the field on the host entity embedding this entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'archived' => array(
        'description' => 'Boolean indicating whether the field collection item is archived.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'item_id',
    ),
  );
  $schema['field_collection_item_revision'] = array(
    'description' => 'Stores revision information about field collection items.',
    'fields' => array(
      'revision_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique revision ID.',
      ),
      'item_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'Field collection item ID.',
      ),
    ),
    'primary key' => array(
      'revision_id',
    ),
    'indexes' => array(
      'item_id' => array(
        'item_id',
      ),
    ),
    'foreign keys' => array(
      'versioned_field_collection_item' => array(
        'table' => 'field_collection_item',
        'columns' => array(
          'item_id' => 'item_id',
        ),
      ),
    ),
  );
  if (module_exists('entitycache')) {
    $schema['cache_entity_field_collection_item'] = drupal_get_schema_unprocessed('system', 'cache');
    $schema['cache_entity_field_collection_item']['description'] = 'Cache table used to store field_collection_item entity records.';
  }
  return $schema;
}