You are here

function flexiform_schema in Flexiform 7

Implements hook_schema().

File

./flexiform.install, line 13
Sets up the base table for our entity and a table to store information about the entity types.

Code

function flexiform_schema() {
  $schema = array();
  $schema['flexiform'] = array(
    'description' => 'Stores information about defined flexiforms.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique flexiform identifier.',
      ),
      'form' => array(
        'description' => 'The machine-readable name of this flexiform.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this flexiform.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'form_group' => array(
        'description' => 'The group that this flexiform belongs to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'general',
      ),
      'builder' => array(
        'description' => 'The builder class for this form',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'FlexiformBuilderFlexiform',
      ),
      'base_entity' => array(
        'description' => 'The base entity type of the form.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'base_entity_bundle' => array(
        'description' => 'The base entity type of the form.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'advanced' => array(
        'description' => 'Select the type of form that is submitted. 0 for simple, 1 for complex/advanced',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this flexiform in relation to others.',
      ),
      'entities' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of entities involved in this flexiform.',
      ),
      'elements' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of elements related to this flexiform.',
      ),
      'displays' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of displays of this flexiform.',
      ),
      'access' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of access settings for this flexiform.',
      ),
      'settings' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of general settings for this flexiform.',
      ),
    ) + entity_exportable_schema_fields(),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'form' => array(
        'form',
      ),
    ),
  );
  $schema['flexiform_display'] = array(
    'description' => 'Stores information about flexiform displays.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The primary identifier of the flexiform.',
      ),
      'form' => array(
        'description' => 'The machine-readable name of this flexiform.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'display' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'description' => 'The tag string associated with this flexiform',
      ),
    ),
    'unique keys' => array(
      'form_display' => array(
        'form',
        'display',
      ),
    ),
    'indexes' => array(
      'id' => array(
        'id',
      ),
      'form' => array(
        'form',
      ),
      'display' => array(
        'display',
      ),
    ),
  );
  $schema['flexiform_tags'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The primary identifier of the flexiform.',
      ),
      'tag' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'description' => 'The tag string associated with this flexiform',
      ),
    ),
    'primary key' => array(
      'id',
      'tag',
    ),
    'foreign keys' => array(
      'table' => 'flexiform',
      'columns' => array(
        'id' => 'id',
      ),
    ),
  );
  return $schema;
}