You are here

function messaging_schema in Messaging 6.2

Same name and namespace in other branches
  1. 6.4 messaging.install \messaging_schema()
  2. 6 messaging.install \messaging_schema()
  3. 6.3 messaging.install \messaging_schema()
  4. 7 messaging.install \messaging_schema()

Implementation of hook_schema().

File

./messaging.install, line 6

Code

function messaging_schema() {
  $schema['messaging_store'] = array(
    'description' => 'Stores queued messages to be sent or sent messages as logs.',
    'fields' => array(
      'mqid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Unique message id.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {user}.uid for destination if it is a unique destination.',
      ),
      'sender' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {user}.uid who sent the message if any.',
      ),
      'method' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Messaging send method key.',
      ),
      'destination' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Destination identifier, it may be an email address.',
      ),
      'subject' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Message subject, single text line.',
      ),
      'body' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Message body, multiple text line.',
      ),
      'params' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'Additional serialized parameters.',
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp, when the message was created/stored.',
      ),
      'sent' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp, when the message was sent.',
      ),
      'cron' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Will be 1 if row marked for processing on cron.',
      ),
      'queue' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Will be 1 if this is a queued message.',
      ),
      'log' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Will be 1 if this is a message log.',
      ),
    ),
    'primary key' => array(
      'mqid',
    ),
    'indexes' => array(
      'cron' => array(
        'cron',
      ),
      'queue' => array(
        'queue',
      ),
      'log' => array(
        'log',
      ),
    ),
  );

  /*
  $schema['messaging_user'] = array(
    'description' => 'User variables for messaging',
    'fields' => array(
      'uid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'name' => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => ''),
      'value'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'text' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
    ),
    'primary key' => array('uid', 'name')
  );
  */
  $schema['messaging_message_parts'] = array(
    'description' => 'Templates for message composition.',
    'fields' => array(
      'type' => array(
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Message group key.',
      ),
      'method' => array(
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Messaging send method.',
      ),
      'msgkey' => array(
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Message part key, should be unique within a group (header, footer,..).',
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Module that owns this template.',
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Message template, multiline text with tokens for replacement.',
      ),
    ),
    'indexes' => array(
      'type' => array(
        'type',
      ),
      'method' => array(
        'method',
      ),
      'msgkey' => array(
        'msgkey',
      ),
    ),
  );
  return $schema;
}