You are here

function heartbeat_schema in Heartbeat 7

Same name and namespace in other branches
  1. 8 heartbeat.install \heartbeat_schema()
  2. 6.4 heartbeat.install \heartbeat_schema()
  3. 6.3 heartbeat.install \heartbeat_schema()

Implementation of hook_schema().

File

./heartbeat.install, line 36
Installation file for the heartbeat module. @author Jochen Stals - Menhir - www.menhir.be

Code

function heartbeat_schema() {
  $schema = array();
  $schema += _heartbeat_update_7010();
  $schema['heartbeat_messages'] = array(
    'description' => t('Table that contains predefined messages that can be used in heartbeat views.'),
    // CTools export definitions.
    'export' => array(
      'key' => 'message_id',
      'key name' => 'Message ID',
      'primary key' => 'message_id',
      'bulk export' => TRUE,
      'identifier' => 'heartbeatmessagetemplate',
      'object' => 'HeartbeatMessageTemplate',
      'default hook' => 'heartbeat_template_info',
      'list callback' => 'heartbeat_templates_names',
      'delete callback' => 'heartbeat_message_template_delete',
      //'export callback' => 'heartbeat_message_template_export',
      'can disable' => TRUE,
      'api' => array(
        'owner' => 'heartbeat',
        'api' => 'heartbeat',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'hid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique heartbeat_messages event ID.'),
        'no export' => TRUE,
      ),
      'message_id' => array(
        'type' => 'varchar',
        'length' => 250,
        'not null' => FALSE,
        'default' => '',
        'description' => t('The message id which is unique to identify activity.'),
      ),
      'description' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Description and/or help text.'),
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of log message to be passed into the t() function.'),
        'alias' => 'message_orig',
      ),
      'message_concat' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of translatable log message for in concatenated form.'),
        'alias' => 'message_concat_orig',
      ),
      'perms' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 4,
        'description' => t('Permissions for this message.'),
      ),
      'group_type' => array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => 'single',
        'description' => t('The group type of the template'),
      ),
      'concat_args' => array(
        'description' => t('Arguments for concatenation message.'),
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => FALSE,
      ),
      'variables' => array(
        'description' => t('Variables to parse into the message (used in message).'),
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => FALSE,
      ),
      'attachments' => array(
        'description' => t('Attachments on messages.'),
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'hid',
    ),
    'indexes' => array(
      'message_id' => array(
        'message_id',
      ),
    ),
  );
  $schema['heartbeat_activity'] = array(
    'description' => t('Table that contains logs of all user triggerable actions.'),
    'fields' => array(
      'uaid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique heartbeat_activity event ID.'),
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {users}.uid of the user who triggered the event (requester).'),
      ),
      'uid_target' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
        'description' => t('The target User ID'),
      ),
      'nid' => array(
        'description' => t('The Node ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'nid_target' => array(
        'description' => t('The target Node ID (E.g. Group id, node reference, ...).'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'cid' => array(
        'description' => t('The target comment ID (optional).'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'access' => array(
        'type' => 'int',
        'not null' => TRUE,
        'size' => 'tiny',
        'description' => t('Access for this message to others.'),
        'default' => 0,
      ),
      'message_id' => array(
        'type' => 'varchar',
        'length' => 250,
        'not null' => FALSE,
        'default' => '',
        'description' => t('The message id which links to the heartbeat message.'),
      ),
      'timestamp' => array(
        'description' => t('The activity\'s unix timestamp when action occurred'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => FALSE,
        'default' => 'en',
        'description' => t('language for a log".'),
      ),
      'variables' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'),
      ),
    ),
    'primary key' => array(
      'uaid',
    ),
    'indexes' => array(
      'timestamp' => array(
        'timestamp',
      ),
      'uid' => array(
        'uid',
      ),
      'message_id' => array(
        'message_id',
      ),
      'uid_target' => array(
        'uid_target',
      ),
      'nid' => array(
        'nid',
      ),
      'nid_target' => array(
        'nid_target',
      ),
      'cid' => array(
        'cid',
      ),
      'language' => array(
        'language',
      ),
    ),
  );
  $schema['heartbeat_activity']['fields']['in_group'] = array(
    'type' => 'int',
    'not null' => TRUE,
    'size' => 'big',
    'description' => t('Indicates whether the activity is related to a group.'),
    'default' => 0,
  );
  $schema['heartbeat_activity']['indexes']['in_group'] = array(
    'in_group',
  );
  $schema['heartbeat_user_templates'] = heartbeat_install_table_user_templates();
  return $schema;
}