You are here

function message_digest_schema in Message Digest 8

Same name and namespace in other branches
  1. 7 message_digest.install \message_digest_schema()

Implements hook_schema().

Add the message_digest table.

1 call to message_digest_schema()
message_digest_update_8103 in ./message_digest.install
Issue 3060135 Add index on {message_digest}.mid, drop unique key if present.

File

./message_digest.install, line 20
Install and update hooks for the Message Digest module.

Code

function message_digest_schema() {
  $schema['message_digest'] = [
    'description' => 'Storage of all sent messages for use in message digests',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Numeric message notification ID.',
      ],
      'mid' => [
        'description' => 'The message ID of the originating message.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ],
      'entity_type' => [
        'description' => 'The entity type the message pertains to. This is used for grouping digests.',
        'type' => 'varchar',
        'length' => EntityTypeInterface::ID_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ],
      'entity_id' => [
        'description' => 'The entity ID the message should be grouped with.',
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 128,
      ],
      'receiver' => [
        'description' => 'The user ID of the acting user.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ],
      'notifier' => [
        'description' => 'The notification method used to send the notification.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'sent' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Boolean for whether the message has already been sent in a digest or not.',
      ],
      'timestamp' => [
        'description' => 'When the message instance was recorded.',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'id',
    ],
    'indexes' => [
      'aggregate' => [
        'timestamp',
        'sent',
        'notifier',
      ],
      'sent' => [
        'receiver',
        'notifier',
      ],
      'mid' => [
        'mid',
      ],
    ],
  ];
  return $schema;
}