You are here

function user_activity_schema in Heartbeat 6.2

Implementation of hook_schema().

File

user_activity/user_activity.install, line 23

Code

function user_activity_schema() {
  $schema['heartbeat_messages'] = array(
    'description' => t('Table that contains predefined messages that can be used in heartbeat views.'),
    'fields' => array(
      'hid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique heartbeat_messages event ID.'),
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of log message to be passed into the t() function.'),
      ),
      'message_concat' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of translatable log message for in concatenated form.'),
      ),
      'concat_args' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Arguments for concatenation message.'),
      ),
      // The messages depend most on "the event" ,
      // "something that happened" worth logging.
      'event' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('user activity action to hook.'),
      ),
      'karma_index' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t('The karma index value for this kind of event.'),
        'default' => 1,
      ),
      'description' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Description and/or help text.'),
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('module where the message is defined.'),
      ),
      'variables' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Variables to parse into the message (used in message).'),
      ),
    ),
    'primary key' => array(
      'hid',
    ),
    'indexes' => array(),
  );
  $schema['user_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 user_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_target' => array(
        'description' => t('The target Node ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'hid' => array(
        'description' => t('The heartbeats message ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of log message to be passed into the t() function.'),
      ),
      'timestamp' => array(
        'description' => t('The activity\'s unix timestamp when action occurred'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'event' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('Event type that is hooked. For example "user hook, login operation" or "nodeapi hook, insert operation".'),
      ),
      'language' => array(
        'type' => 'char',
        'length' => 4,
        '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',
      ),
      'uid_target' => array(
        'uid_target',
      ),
      'nid_target' => array(
        'nid_target',
      ),
      'language' => array(
        'language',
      ),
    ),
  );
  return $schema;
}