field_sql_storage_schema

Versions
7
field_sql_storage_schema()

Implement hook_schema().

Code

modules/field/modules/field_sql_storage/field_sql_storage.install, line 11

<?php
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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.