You are here

function messaging_schema in Messaging 6.4

Same name and namespace in other branches
  1. 6 messaging.install \messaging_schema()
  2. 6.2 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.',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Language code.',
      ),
      '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.',
      ),
      'error' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Error code.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'Additional serialized parameters.',
      ),
    ),
    'primary key' => array(
      'mqid',
    ),
    'indexes' => array(
      'cron' => array(
        'cron',
      ),
      'queue' => array(
        'queue',
      ),
      'log' => array(
        'log',
      ),
    ),
  );
  $schema['messaging_destination'] = array(
    'description' => 'Stores message destination for users and non users.',
    'fields' => array(
      'mdid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Unique destination id.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {user}.uid for destination if it belongs to a registered user.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 60,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Destination type: mail, xmpp, etc.',
      ),
      'address' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Destination identifier, it may be an email address.',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'size' => 'tiny',
        'description' => 'Destination status: 1= active, 0 = inactive.',
      ),
      'sent' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp, when the last message was sent to this address.',
      ),
    ),
    'primary key' => array(
      'mdid',
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'address' => array(
        'address',
      ),
    ),
  );
  return $schema;
}