You are here

function private_message_update_8004 in Private Message 8.2

Install the module shcema.

File

./private_message.install, line 120
Holds install and update hooks for the Private Message module.

Code

function private_message_update_8004() {
  $database = \Drupal::database();

  // Create database table.
  if (!$database
    ->schema()
    ->tableExists('pm_thread_history')) {
    $database
      ->schema()
      ->createTable('pm_thread_history', [
      'description' => 'A record of which {users} have read which {private_message_threads}.',
      'fields' => [
        'uid' => [
          'description' => 'The {users}.uid that read the {private_message_threads} id.',
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
        ],
        'thread_id' => [
          'description' => 'The {private_message_threads}.id that was read.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ],
        'access_timestamp' => [
          'description' => 'The Unix timestamp at which the read occurred.',
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
        ],
        'delete_timestamp' => [
          'description' => 'The Unix timestamp at which the delete occurred.',
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
        ],
      ],
      'primary key' => [
        'uid',
        'thread_id',
      ],
      'indexes' => [
        'thread_id' => [
          'thread_id',
        ],
      ],
    ]);
  }
}