You are here

function privatemsg_schema in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg.install \privatemsg_schema()
  2. 6 privatemsg.install \privatemsg_schema()
  3. 7 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,
      ),
      'reply_to_mid' => array(
        'description' => 'mid of the message this is a reply to (if any)',
        'type' => 'int',
        'default' => 0,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
    ),
    'primary key' => array(
      'mid',
    ),
  );
  $schema['pm_setting'] = array(
    'description' => '{pm_setting} holds user specific (including defaults) settings',
    'fields' => array(
      'id' => array(
        'description' => 'Together with type, associates a setting to a user, role, global default, ...',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'type' => array(
        'description' => 'Together with id, associates a setting to a user, role, global default, ...',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'setting' => array(
        'description' => 'The name of a setting',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'value' => array(
        'description' => 'Holds the value of a given setting',
        'type' => 'int',
      ),
    ),
    'primary key' => array(
      'id',
      'type',
      'setting',
    ),
  );
  return $schema;
}