You are here

function privatemsg_schema in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.install \privatemsg_schema()
  2. 6 privatemsg.install \privatemsg_schema()
  3. 7.2 privatemsg.install \privatemsg_schema()

Implements hook_schema().

File

./privatemsg.install, line 11
Install file for privatemsg.module

Code

function privatemsg_schema() {
  $schema = array();
  $schema['pm_index'] = array(
    'description' => '{pm_index} holds indexing information about messages and recipients for fast retrieval',
    'fields' => array(
      'mid' => array(
        'description' => 'Private Message ID',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'thread_id' => array(
        'description' => 'Messages thread ID',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'recipient' => array(
        'description' => 'ID of the recipient object, typically user',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'is_new' => array(
        'description' => 'Whether the user has read this message',
        'type' => 'int',
        'default' => 1,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'deleted' => array(
        'description' => 'Whether the user has deleted this message',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'type' => array(
        'description' => 'Type of recipient object',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'user',
      ),
    ),
    'primary key' => array(
      'mid',
      'recipient',
      'type',
    ),
    'indexes' => array(
      'list' => array(
        'recipient',
        'type',
        'deleted',
        'is_new',
      ),
      'messages' => array(
        'mid',
        'recipient',
        'type',
      ),
      'participants' => array(
        'thread_id',
        'recipient',
        'type',
        'deleted',
      ),
    ),
  );
  $schema['pm_message'] = array(
    'description' => '{pm_messages} holds the message information',
    'fields' => array(
      'mid' => array(
        'description' => 'Private Message ID',
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'author' => array(
        'description' => 'UID of the author',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'subject' => array(
        'description' => 'Subject text of the message',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'body' => array(
        'description' => 'Body of the message',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'format' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'The {filter_formats}.format of the message text.',
      ),
      'timestamp' => array(
        'description' => 'Time when the message was sent',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'has_tokens' => array(
        'description' => 'Indicates if the message has tokens',
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'mid',
    ),
  );
  $schema['pm_disable'] = array(
    'description' => '{pm_disable} holds the list of users that have disabled private messaging',
    'fields' => array(
      'uid' => array(
        'description' => 'ID of the user',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
    ),
    'primary key' => array(
      'uid',
    ),
  );
  return $schema;
}