-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_activity_tracker.install
87 lines (80 loc) · 2.58 KB
/
entity_activity_tracker.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @file
* Entity Activity Tracker module install/schema/update hooks.
*/
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_schema().
*/
function entity_activity_tracker_schema() {
$schema = [];
$schema['entity_activity_tracker'] = [
'description' => 'Store activity value of content entities.',
'fields' => [
'activity_id' => [
'description' => 'Primary Key: Activity Record ID.',
'type' => 'serial',
'not null' => TRUE,
],
'entity_type' => [
'description' => 'Tracked entity type, e.g. "node" or "group".',
'type' => 'varchar_ascii',
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'not null' => TRUE,
],
'bundle' => [
'description' => 'Entity bundle of tracked entity.',
'type' => 'varchar_ascii',
'length' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'not null' => TRUE,
],
'entity_id' => [
'description' => 'The unique ID of the entity, e.g. the gid or nid.',
'type' => 'varchar_ascii',
'length' => ConfigEntityStorage::MAX_ID_LENGTH,
'not null' => TRUE,
],
'activity' => [
'description' => 'The value that defines how active is entity.',
'type' => 'int',
'unsigned' => TRUE,
],
'created' => [
'description' => 'The UNIX time stamp for the activity first record.',
'type' => 'int',
'unsigned' => TRUE,
'disp-size' => 11,
],
'changed' => [
'description' => 'The UNIX time stamp for the activity last update.',
'type' => 'int',
'unsigned' => TRUE,
'disp-size' => 11,
],
'last_decay' => [
'description' => 'The UNIX time stamp representing when last decay happened.',
'type' => 'int',
'unsigned' => TRUE,
'disp-size' => 11,
],
],
'primary key' => ['activity_id'],
'indexes' => [
'index_entity_type' => ['entity_type'],
'index_entity_entity_id' => ['entity_id'],
],
];
return $schema;
}
/**
* Add indexes for entity_id and entity_type fields.
*/
function entity_activity_tracker_update_9301(&$sandbox) {
$entity_activity_tracker_schema = entity_activity_tracker_schema();
$spec = $entity_activity_tracker_schema['entity_activity_tracker'];
$schema = \Drupal::database()->schema();
$schema->addIndex('entity_activity_tracker', 'index_entity_type', ['entity_type'], $spec);
$schema->addIndex('entity_activity_tracker', 'index_entity_entity_id', ['entity_id'], $spec);
}