You are here

function paragraphs_schema in Paragraphs 7

Implements hook_schema().

File

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

Code

function paragraphs_schema() {
  $schema = array();
  $schema['paragraphs_bundle'] = array(
    'description' => 'Stores information about paragraphs bundles.',
    'fields' => array(
      'bundle' => array(
        'description' => 'The machine-readable name of this bundle.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The human-readable name of this bundle.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'label' => array(
        'description' => 'A user-facing label for this bundle.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'description' => array(
        'description' => 'A brief description of this bundle.',
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'medium',
        'translatable' => TRUE,
      ),
      'locked' => array(
        'description' => 'A boolean indicating whether the administrator can change the machine name of this bundle.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
    ),
    'primary key' => array(
      'bundle',
    ),
  );
  $schema['paragraphs_item'] = array(
    'description' => 'Stores information about paragraph items.',
    'fields' => array(
      'item_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique paragraph item ID.',
      ),
      'revision_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'Default revision ID.',
      ),
      'bundle' => array(
        'description' => 'The bundle of this paragraph item.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'field_name' => array(
        'description' => 'Field name of the host entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'archived' => array(
        'description' => 'Boolean indicating whether the paragraph item is archived.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'item_id',
    ),
  );
  $schema['paragraphs_item_revision'] = array(
    'description' => 'Stores revision information about paragraph 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' => 'Paragraph item ID.',
      ),
    ),
    'primary key' => array(
      'revision_id',
    ),
    'indexes' => array(
      'item_id' => array(
        'item_id',
      ),
    ),
    'foreign keys' => array(
      'versioned_paragraphs_item' => array(
        'table' => 'paragraphs_item',
        'columns' => array(
          'item_id' => 'item_id',
        ),
      ),
    ),
  );
  return $schema;
}