HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/public_html/core/modules/history/history.install
<?php

/**
 * @file
 * Installation functions for History module.
 */

use Drupal\Core\Database\Database;

/**
 * Implements hook_schema().
 */
function history_schema() {
  $schema['history'] = [
    'description' => 'A record of which {users} have read which {node}s.',
    'fields' => [
      'uid' => [
        'description' => 'The {users}.uid that read the {node} nid.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
      'nid' => [
        'description' => 'The {node}.nid that was read.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'timestamp' => [
        'description' => 'The Unix timestamp at which the read occurred.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => ['uid', 'nid'],
    'indexes' => [
      'nid' => ['nid'],
    ],
  ];

  return $schema;
}

/**
 * Change {history}.nid to an unsigned int in order to match {node}.nid.
 */
function history_update_8101() {
  $schema = Database::getConnection()->schema();
  $schema->dropPrimaryKey('history');
  $schema->dropIndex('history', 'nid');
  $schema->changeField('history', 'nid', 'nid', [
    'description' => 'The {node}.nid that was read.',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ]);
  $schema->addPrimaryKey('history', ['uid', 'nid']);
  $spec = [
    'description' => 'A record of which {users} have read which {node}s.',
    'fields' => [
      'uid' => [
        'description' => 'The {users}.uid that read the {node} nid.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
      'nid' => [
        'description' => 'The {node}.nid that was read.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'timestamp' => [
        'description' => 'The Unix timestamp at which the read occurred.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => ['uid', 'nid'],
    'indexes' => [
      'nid' => ['nid'],
    ],
  ];
  $schema->addIndex('history', 'nid', ['nid'], $spec);
}