You are here

function entityform_schema in Entityform 7

Same name and namespace in other branches
  1. 8.2 entityform.install \entityform_schema()
  2. 7.2 entityform.install \entityform_schema()

Implements hook_schema().

File

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

Code

function entityform_schema() {
  $schema = array();
  $schema['entityform'] = array(
    'description' => 'The base table for entityform entities.',
    'fields' => array(
      'entityform_id' => array(
        'description' => 'Primary Key: Identifier for a entityform.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {entityform_type}.type of this entityform.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'The language of the entityform.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the entityform was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the entityform was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => "The {users}.uid of the associated user.",
      ),
      'draft' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => "Wheter this form submission is a draft.",
      ),
    ),
    'primary key' => array(
      'entityform_id',
    ),
    'indexes' => array(
      'type' => array(
        'type',
      ),
      'uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'uid' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
      'type' => array(
        'table' => 'entityform_type',
        'columns' => array(
          'type' => 'type',
        ),
      ),
    ),
  );
  $schema['entityform_type'] = array(
    'description' => 'Stores information about defined entityform types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entityform type identifier.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this entityform type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this entityform type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this entityform type in relation to others.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this entityform type.',
      ),
    ) + entity_exportable_schema_fields(),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}