-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathithenticate.install
97 lines (90 loc) · 2.56 KB
/
ithenticate.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
88
89
90
91
92
93
94
95
96
97
<?php
/**
* @file
* Contains installation functions and hooks for the ithenticate module.
*/
/**
* Implements hook_schema().
*/
function ithenticate_schema() {
$schema = [];
$schema['ithenticate_documents'] = [
'description' => 'Stores information about iThenticate documents.',
'fields' => [
'entity_type' => [
'description' => 'The entity type.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
],
'bundle' => [
'description' => 'The bundle.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
],
'entity_id' => [
'description' => 'The entity ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'revision_id' => [
'description' => 'The entity version ID.',
'type' => 'int',
'unsigned' => TRUE,
],
'ithenticate_document_id' => [
'description' => 'The document ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
'ithenticate_report_id' => [
'description' => 'The report ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
'ithenticate_report_url' => [
'description' => 'The report URL.',
'type' => 'varchar',
'length' => '1024',
'not null' => FALSE,
],
'percent_match' => [
'description' => 'The match percent for the document.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
],
'primary key' => ['entity_type', 'bundle', 'entity_id'],
];
return $schema;
}
/**
* Install the percent_match database column.
*/
function ithenticate_update_0700(&$sandbox) {
db_add_field('ithenticate_documents', 'percent_match', [
'description' => 'The match percent for the document.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
]);
}
/**
* Install the revision_id database column.
*/
function ithenticate_update_0701() {
db_add_field('ithenticate_documents', 'revision_id', [
'description' => 'The entity version ID.',
'type' => 'int',
'unsigned' => TRUE,
]);
// The revision ID should be filled with the `node` table. The `node.nid` is
// the same as the `ithenticate_documents.entity_id` and the `node.vid` is the
// same as the `ithenticate_documents.revision_id`.
db_query("UPDATE {ithenticate_documents} SET revision_id = (SELECT vid FROM {node} WHERE nid = {ithenticate_documents}.entity_id)")->execute();
}