Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / history / history.install
1 <?php
2
3 /**
4  * @file
5  * Installation functions for History module.
6  */
7
8 use Drupal\Core\Database\Database;
9
10 /**
11  * Implements hook_schema().
12  */
13 function history_schema() {
14   $schema['history'] = [
15     'description' => 'A record of which {users} have read which {node}s.',
16     'fields' => [
17       'uid' => [
18         'description' => 'The {users}.uid that read the {node} nid.',
19         'type' => 'int',
20         'not null' => TRUE,
21         'default' => 0,
22       ],
23       'nid' => [
24         'description' => 'The {node}.nid that was read.',
25         'type' => 'int',
26         'unsigned' => TRUE,
27         'not null' => TRUE,
28         'default' => 0,
29       ],
30       'timestamp' => [
31         'description' => 'The Unix timestamp at which the read occurred.',
32         'type' => 'int',
33         'not null' => TRUE,
34         'default' => 0,
35       ],
36     ],
37     'primary key' => ['uid', 'nid'],
38     'indexes' => [
39       'nid' => ['nid'],
40     ],
41   ];
42
43   return $schema;
44 }
45
46 /**
47  * Change {history}.nid to an unsigned int in order to match {node}.nid.
48  */
49 function history_update_8101() {
50   $schema = Database::getConnection()->schema();
51   $schema->dropPrimaryKey('history');
52   $schema->dropIndex('history', 'nid');
53   $schema->changeField('history', 'nid', 'nid', [
54     'description' => 'The {node}.nid that was read.',
55     'type' => 'int',
56     'unsigned' => TRUE,
57     'not null' => TRUE,
58     'default' => 0,
59   ]);
60   $schema->addPrimaryKey('history', ['uid', 'nid']);
61   $spec = [
62     'description' => 'A record of which {users} have read which {node}s.',
63     'fields' => [
64       'uid' => [
65         'description' => 'The {users}.uid that read the {node} nid.',
66         'type' => 'int',
67         'not null' => TRUE,
68         'default' => 0,
69       ],
70       'nid' => [
71         'description' => 'The {node}.nid that was read.',
72         'type' => 'int',
73         'unsigned' => TRUE,
74         'not null' => TRUE,
75         'default' => 0,
76       ],
77       'timestamp' => [
78         'description' => 'The Unix timestamp at which the read occurred.',
79         'type' => 'int',
80         'not null' => TRUE,
81         'default' => 0,
82       ],
83     ],
84     'primary key' => ['uid', 'nid'],
85     'indexes' => [
86       'nid' => ['nid'],
87     ],
88   ];
89   $schema->addIndex('history', 'nid', ['nid'], $spec);
90 }